- Notifications
You must be signed in to change notification settings - Fork 781
Add scroll element into view #1083
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
Conversation
| """Scrolls an element from given ``locator`` into view. | ||
| """ | ||
| element = self.find_element(locator) | ||
| self.driver.execute_script("arguments[0].scrollIntoView()", element) |
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.
I know that some users are actually using the library on places where JavaScript is not available. Therefore it should be better use Selenium ActionChains. Example like this: ActionChains(self.driver).(element).perform()
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.
I see. However, ActionChains has no method to do that.
https://seleniumhq.github.io/selenium/docs/api/py/webdriver/selenium.webdriver.common.action_chains.html.
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.
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.
This only hovers element. I tested in Firefox and it does not scroll.
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.
It works with Chrome and Edge. Also there is an exception raised when trying with Firefox.
Traceback (most recent call last): File "test.py", line 16, in <module> ActionChains(driver).move_to_element(element).perform() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/action_chains.py", line 80, in perform self.w3c_actions.perform() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/actions/action_builder.py", line 76, in perform self.driver.execute(Command.W3C_ACTIONS, enc) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute self.error_handler.check_response(response) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.MoveTargetOutOfBoundsException: Message: (183.5, 5330.85009765625) is out of bounds of viewport width (1280) and height (779) I did raise an issue to the Selenium issue tracker: SeleniumHQ/selenium#5601. For mean time, make: if browser is Firefox then use JavaScript, else use ActionChains
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 it scroll element on my test scroll 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.
I didn't try your test page, but this did work with Chrome and Edge: https://gist.github.com/aaltat/a7f71e960d1bc3c6f90bfebb216162f0
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.
I tested it in Chrome and action chain solution works. I will update pr
| | ||
| @keyword | ||
| def scroll_element_into_view(self, locator): | ||
| """Scrolls an element from given ``locator`` into view. |
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.
Change doc string to:
"""Scrolls an element identified by ``locator`` into view. See the `Locating elements` section for details about the locator syntax. New in SeleniumLibrary 3.2.0 """ d564a25 to 49a3f0e Compare 49a3f0e to 9117634 Compare | It looks like test with appveyor did fail for some reason. I hate FF too. I did restart the build and lets see how it goes. Code and tests look OK. |
| Firefox is behaving badly and it has come impossible to get it stable. I did disable the FF build with appveyor. |
| This didn't get added to the changes list .... @drobota would you like credit for adding this to RF? I can update the changes file https://github.com/robotframework/SeleniumLibrary/blob/master/CHANGES.rst if you would like .. or you can submit a new PR |
| I don't see this in the keywords list either? |
| This feature is in the master code line, but it's unreleased. Therefore the keyword documentation is not updated. |
| we could put it in the changes file, i asked the person who originated the idea for that keyword if he wanted credit but he never responded. …On Thu, Jul 19, 2018 at 2:02 AM Tatu Aalto ***@***.***> wrote: This feature is in the master code line, but it's unreleased. Therefore the keyword documentation is not updated. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#1083 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAAoXdLDZpRlGZOMEfxy98JFS6mjbqbJks5uIC8NgaJpZM4SkvZO> . -- Ruby: http://blog.rubygeek.com - http://www.twitter.com/rubygeek http://www.linkedin.com/in/nolastowe - my linkedin profile http://github.com/rubygeek - my code |
No description provided.