Home > Net >  How to scroll furthest to the right using Selenium and Python
How to scroll furthest to the right using Selenium and Python

Time:04-05

If I want to scroll to the end of a page I use the following:

driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

What's the equivalent for scrolling all the way to the right? My first guess was:

driver.execute_script("window.scrollTo(document.body.scrollWidth, 0);")

However, this didn't work and gave the following error:

JavascriptException}Message: javascript error: Cannot read properties of null (reading 'scrollWidth')

I only want the so-called golf green (the green circle on the right)

URL = 'https://apps.frs-dev.imgarena.dev/golf/3d/courses/PGA-4/holeNo/13/map_preview.svg'

CodePudding user response:

Instead of directional scrolling an easier approach would be to identify the desired element inducing green_circle_on_the_right.png

  • Related