-
Notifications
You must be signed in to change notification settings - Fork 568
Move search context methods from webdriver and webelement to search_context #461
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b0cc81e
Move ios search context methods to search_context file
ki4070ma 0e60429
Move android search text methods
ki4070ma 0f91162
Move windows search context
ki4070ma 93b0998
Move mobile search context
ki4070ma a535b10
Divided search_context into each class
ki4070ma 8f52dd0
Move custom and image methods
ki4070ma 8a11141
Move contents in search_context.py to __init__.py
ki4070ma 2d960ef
Add rtype to each docstring for auto completion in IDE
ki4070ma 666f206
Add comments
ki4070ma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #!/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. | ||
|
|
||
| # pylint: disable=abstract-method | ||
|
|
||
| from selenium import webdriver | ||
| from selenium.webdriver.remote.webelement import \ | ||
| WebElement as SeleniumWebElement | ||
|
|
||
| from .android import AndroidSearchContext | ||
| from .custom import CustomSearchContext | ||
| from .ios import iOSSearchContext | ||
| from .mobile import MobileSearchContext | ||
| from .windows import WindowsSearchContext | ||
|
|
||
|
|
||
| class AppiumSearchContext(webdriver.Remote, | ||
| AndroidSearchContext, | ||
| CustomSearchContext, | ||
| iOSSearchContext, | ||
| MobileSearchContext, | ||
| WindowsSearchContext): | ||
| """Returns appium driver search conext""" | ||
|
|
||
|
|
||
| class AppiumWebElementSearchContext(SeleniumWebElement, | ||
| AndroidSearchContext, | ||
| CustomSearchContext, | ||
| iOSSearchContext, | ||
| MobileSearchContext, | ||
| WindowsSearchContext): | ||
| """Returns appium web element search context""" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
appium/webdriver/extensions/search_context/base_search_context.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/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. | ||
|
|
||
| # pylint: disable=abstract-method | ||
|
|
||
|
|
||
| class BaseSearchContext(object): | ||
| """Used by each search context. Dummy find_element/s are for preventing pylint error""" | ||
|
|
||
| def find_element(self, by=None, value=None): | ||
| raise NotImplementedError | ||
|
|
||
| def find_elements(self, by=None, value=None): | ||
| raise NotImplementedError |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/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. | ||
|
|
||
| # pylint: disable=abstract-method | ||
|
|
||
| from appium.webdriver.common.mobileby import MobileBy | ||
|
|
||
| from .base_search_context import BaseSearchContext | ||
|
|
||
|
|
||
| class CustomSearchContext(BaseSearchContext): | ||
| """Define search context for custom plugin""" | ||
|
|
||
| def find_element_by_custom(self, selector): | ||
| """Finds an element in conjunction with a custom element finding plugin | ||
|
|
||
| Args: | ||
| selector (str): a string of the form "module:selector", where "module" is | ||
| the shortcut name given in the customFindModules capability, and | ||
| "selector" is the string that will be passed to the custom element | ||
| finding plugin itself | ||
|
|
||
| Usage: | ||
| driver.find_element_by_custom("foo:bar") | ||
|
|
||
| Returns: | ||
| `appium.webdriver.webelement.WebElement` | ||
|
|
||
| # To enable auto completion in PyCharm(IDE) | ||
| :rtype: `appium.webdriver.webelement.WebElement` | ||
| """ | ||
| return self.find_element(by=MobileBy.CUSTOM, value=selector) | ||
|
|
||
| def find_elements_by_custom(self, selector): | ||
| """Finds elements in conjunction with a custom element finding plugin | ||
|
|
||
| Args: | ||
| selector: a string of the form "module:selector", where "module" is | ||
| the shortcut name given in the customFindModules capability, and | ||
| "selector" is the string that will be passed to the custom element | ||
| finding plugin itself | ||
|
|
||
| Usage: | ||
| driver.find_elements_by_custom("foo:bar") | ||
|
|
||
| Returns: | ||
| :obj:`list` of :obj:`appium.webdriver.webelement.WebElement` | ||
|
|
||
| :rtype: list of `appium.webdriver.webelement.WebElement` | ||
| """ | ||
| return self.find_elements(by=MobileBy.CUSTOM, value=selector) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| #!/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. | ||
|
|
||
| # pylint: disable=abstract-method | ||
|
|
||
| from appium.webdriver.common.mobileby import MobileBy | ||
|
|
||
| from .base_search_context import BaseSearchContext | ||
|
|
||
|
|
||
| class iOSSearchContext(BaseSearchContext): | ||
| """Define search context for iOS""" | ||
|
|
||
| def find_element_by_ios_uiautomation(self, uia_string): | ||
| """Finds an element by uiautomation in iOS. | ||
|
|
||
| Args: | ||
| uia_string (str): The element name in the iOS UIAutomation library | ||
|
|
||
| Usage: | ||
| driver.find_element_by_ios_uiautomation('.elements()[1].cells()[2]') | ||
|
|
||
| Returns: | ||
| `appium.webdriver.webelement.WebElement` | ||
|
|
||
| # To enable auto completion in PyCharm(IDE) | ||
| :rtype: `appium.webdriver.webelement.WebElement` | ||
| """ | ||
| return self.find_element(by=MobileBy.IOS_UIAUTOMATION, value=uia_string) | ||
|
|
||
| def find_elements_by_ios_uiautomation(self, uia_string): | ||
| """Finds elements by uiautomation in iOS. | ||
|
|
||
| Args: | ||
| uia_string (str): The element name in the iOS UIAutomation library | ||
|
|
||
| Usage: | ||
| driver.find_elements_by_ios_uiautomation('.elements()[1].cells()[2]') | ||
|
|
||
| Returns: | ||
| :obj:`list` of :obj:`appium.webdriver.webelement.WebElement` | ||
|
|
||
| :rtype: list of `appium.webdriver.webelement.WebElement` | ||
| """ | ||
| return self.find_elements(by=MobileBy.IOS_UIAUTOMATION, value=uia_string) | ||
|
|
||
| def find_element_by_ios_predicate(self, predicate_string): | ||
| """Find an element by ios predicate string. | ||
|
|
||
| Args: | ||
| predicate_string (str): The predicate string | ||
|
|
||
| Usage: | ||
| driver.find_element_by_ios_predicate('label == "myLabel"') | ||
|
|
||
| Returns: | ||
| `appium.webdriver.webelement.WebElement` | ||
|
|
||
| :rtype: `appium.webdriver.webelement.WebElement` | ||
| """ | ||
| return self.find_element(by=MobileBy.IOS_PREDICATE, value=predicate_string) | ||
|
|
||
| def find_elements_by_ios_predicate(self, predicate_string): | ||
| """Finds elements by ios predicate string. | ||
|
|
||
| Args: | ||
| predicate_string (str): The predicate string | ||
|
|
||
| Usage: | ||
| driver.find_elements_by_ios_predicate('label == "myLabel"') | ||
|
|
||
| Returns: | ||
| :obj:`list` of :obj:`appium.webdriver.webelement.WebElement` | ||
|
|
||
| :rtype: list of `appium.webdriver.webelement.WebElement` | ||
| """ | ||
| return self.find_elements(by=MobileBy.IOS_PREDICATE, value=predicate_string) | ||
|
|
||
| def find_element_by_ios_class_chain(self, class_chain_string): | ||
| """Find an element by ios class chain string. | ||
|
|
||
| Args: | ||
| class_chain_string (str): The class chain string | ||
|
|
||
| Usage: | ||
| driver.find_element_by_ios_class_chain('XCUIElementTypeWindow/XCUIElementTypeButton[3]') | ||
|
|
||
| Returns: | ||
| `appium.webdriver.webelement.WebElement` | ||
|
|
||
| :rtype: `appium.webdriver.webelement.WebElement` | ||
| """ | ||
| return self.find_element(by=MobileBy.IOS_CLASS_CHAIN, value=class_chain_string) | ||
|
|
||
| def find_elements_by_ios_class_chain(self, class_chain_string): | ||
| """Finds elements by ios class chain string. | ||
|
|
||
| Args: | ||
| class_chain_string (str): The class chain string | ||
|
|
||
| Usage: | ||
| driver.find_elements_by_ios_class_chain('XCUIElementTypeWindow[2]/XCUIElementTypeAny[-2]') | ||
|
|
||
| Returns: | ||
| :obj:`list` of :obj:`appium.webdriver.webelement.WebElement` | ||
|
|
||
| :rtype: list of `appium.webdriver.webelement.WebElement` | ||
| """ | ||
| return self.find_elements(by=MobileBy.IOS_CLASS_CHAIN, value=class_chain_string) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍