6

I want to scroll the left nav bar (which shows the job list) to the bottom using python, selenium and chromedriver. I tried using:

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

But nothing happened. I'm new to web automation, please let me know if you need anything.

P.S. Page source

Page image

2
  • It is a common issue to scroll inside an HTML element. Check out these answers:stackoverflow.com/questions/27189182/… BTW, you don't need to scroll in order to act on an element, if you need to load new list elements you may just execute the specific script/function in your page (to find this function you have to use brower's developer tool). Commented Dec 18, 2019 at 7:57
  • Thank you furkanayd. Can you please guide me how to find those particular scripts/functions? The above question link was helpful for me though. Commented Dec 18, 2019 at 16:31

1 Answer 1

2

This is the last element job list in the left nav bar:

(//li[contains(@class, 'PaEvOc')])[last()]

To achieve scroll to bottom left nav use .location_once_scrolled_into_view:

element = driver.find_element_by_xpath("(//li[contains(@class, 'PaEvOc')])[last()]")
element.location_once_scrolled_into_view
Sign up to request clarification or add additional context in comments.

1 Comment

How did you manage to find 'PaEvOc' ? I tried to inspect that page again, and could not find PaEvOc or gws-horizon-textlists__li-ed on that page (I presume this is how people found that last element in the past). I am attempting the same exercise and am also stuck similarly to the original poster

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.