Python Forum
Need help trying to scroll a page with selenium
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help trying to scroll a page with selenium
#1
So im trying to scroll a page with selenium to make certain objects visible so that the ChromeDriver can properly select them. Ive been using:

"elem = driver.find_element_by_tag_name('html')"
"elem.send_keys(Keys.END)"

But it doesnt always work right, ive also tried:

"driver.execute_script("window.scrollTo(0, 200))"

This method never works on the page im working on, literally does nothing. How can i scroll a specific amount or to get a certain object in view?

apologies for my formatting if anything is wrong
Reply
#2
That's weird because that method is upvoted a lot at stackoverflow... maybe you call it before the page is loaded? Could you tell what page it is? (I'll test it myself, just have to setup the libs)

from selenium import webdriver

br  = webdriver.Chrome()
print("1")
br.get("https://www.jbzd.pl")
print("2")
br.execute_script("window.scrollTo(0, document.body.scrollHeight)")

input("Press enter to exit the program\n> ")
raise SystemExit
Just tested this simple example and it worked well
Reply
#3
(May-10-2019, 04:54 PM)michalmonday Wrote: That's weird because that method is upvoted a lot at stackoverflow... maybe you call it before the page is loaded? Could you tell what page it is? (I'll test it myself, just have to setup the libs)
from selenium import webdriver br = webdriver.Chrome() print("1") br.get("https://www.jbzd.pl") print("2") br.execute_script("window.scrollTo(0, document.body.scrollHeight)") input("Press enter to exit the program\n> ") raise SystemExit
Just tested this simple example and it worked well

here is the page im trying it on. https://www.travelchannel.com/sweepstake...as-getaway
Reply
#4
It redirects to: https://www.discoveryuk.com/tv-guide/dmax/

Is that supposed to happen?
Reply
#5
(May-10-2019, 06:16 PM)michalmonday Wrote: It redirects to: https://www.discoveryuk.com/tv-guide/dmax/ Is that supposed to happen?

lmao oh jeez. okay try googling "big texas getaway travel channel". shouldnt be discovery, should be travel channel
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I want to be able to scroll up in curses to see previous text. Caiden 1 770 Jul-28-2023, 01:15 PM
Last Post: deanhystad
  How to scroll through results from help(object) 8bitrick 1 1,411 Jan-13-2020, 11:30 PM
Last Post: stullis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020