Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scrollBy() invoked through execute_script is not working on chrome store page using Selenium and Python

I'm using selenium with python 3 and Chrome driver. I'm trying to perform a scroll in a chrome store URL.

This one: https://chrome.google.com/webstore/detail/online-game-zone-new-tab/abalcghoakdcaalbfadaacmapphamklh

No matter what I tried - the site doesn't scroll. Tried running "window.scrollBy" and "window.scrollTo". Tried clicking on "body" first, and other elements - nothing.

current code:

driver.maximize_window()
driver.get(url)
time.sleep(4)
driver.execute_script("window.scrollBy(0, 500)")

What could be the problem? I don't want to send a "down" key or "page down" since I believe I'll need to be more precise.

like image 825
Oron Werner Avatar asked Mar 19 '26 10:03

Oron Werner


1 Answers

Scrolling an element into view seems to be working fine on that webpage. Here's an example:

footer=driver.find_element_by_class_name('e-f-ra-gj')
driver.execute_script("arguments[0].scrollIntoView()", footer)
like image 91
0buz Avatar answered Mar 21 '26 23:03

0buz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!