-
Notifications
You must be signed in to change notification settings - Fork 294
Support applications with multiple webviews. Add scrolling to the visible webview. #329
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
Changes from 4 commits
3ad2e21
e01b13f
aafc846
ec068b0
ffc23ec
8006ea3
bd3bea0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -347,6 +347,54 @@ def get_webelement(self, locator): | |
""" | ||
return self._element_find(locator, True, True) | ||
|
||
def scroll_element_into_view(self, locator): | ||
"""Scrolls an element from given ``locator`` into view. | ||
Arguments: | ||
- ``locator``: The locator to find requested element. Key attributes for | ||
arbitrary elements are ``id`` and ``name``. See `introduction` for | ||
details about locating elements. | ||
Examples: | ||
| Scroll Element Into View | css=div.class | | ||
""" | ||
if isinstance(locator, WebElement): | ||
element = locator | ||
else: | ||
self._info("Scrolling element '%s' into view." % locator) | ||
element = self._element_find(locator, True, True) | ||
script = 'arguments[0].scrollIntoView()' | ||
# pylint: disable=no-member | ||
self._current_application().execute_script(script, element) | ||
return element | ||
|
||
def get_webelement_in_webelement(self, element, locator): | ||
# def _element_find(self, locator, first_only, required, tag=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove comment pleaes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cleaned up the comments |
||
elements = None | ||
if isstr(locator): | ||
_locator = locator | ||
elements = self._element_finder.find(element, _locator, None) | ||
if len(elements) == 0: | ||
raise ValueError("Element locator '" + locator + "' did not match any elements.") | ||
if len(elements) == 0: | ||
return None | ||
return elements[0] | ||
elif isinstance(locator, WebElement): | ||
return locator | ||
|
||
def get_webelements_no_error(self, locator): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does no_error means in the name of the method? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops, I'm new to git and didn't mean to add this this function to the pull request. I thought I could pick and choose commits that would make sense to everyone. the intention though is if the webelement query finds no webelements, instead of throwing an error, it returns an empty array so you can do a get length on it. I still need to experiment if I can accomplish the same thing with a Run Keyword And Continue on Failure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed this function entirely. It can be handled via Run Keyword And Continue On Failure |
||
"""Returns list of [http://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.remote.webelement|WebElement] objects matching ``locator``. | ||
|
||
Example: | ||
| @{elements} | Get Webelements | id=my_element | | ||
| Click Element | @{elements}[2] | | | ||
|
||
This keyword was changed in AppiumLibrary 1.4 in following ways: | ||
- Name is changed from `Get Elements` to current one. | ||
- Deprecated argument ``fail_on_error``, use `Run Keyword and Ignore Error` if necessary. | ||
|
||
New in AppiumLibrary 1.4. | ||
""" | ||
return self._element_find(locator, False, False) | ||
|
||
def get_webelements(self, locator): | ||
"""Returns list of [http://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.remote.webelement|WebElement] objects matching ``locator``. | ||
|
||
|
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.
does this apply to both ios and android
Uh oh!
There was an error while loading. Please reload this page.
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.
Confirmed to work for scrolling elements in a webview on both Android and iOS.