'Python - Selenium: Scroll divided screen | Linkedin job interface

I would like to find a solution for the next problem: As you can see in the picture there is 2 scrolling interface( rails ). I would like to get each job( for making an automated application process ), which I already done, however at once I can get only 9 elements, hence the screen, therefore I need to scroll down each time I got out the current elements. linkedin divided interface

job_titles = driver.find_elements_by_class_name('jobs-search-results__list-item')

for job_title in job_titles:
    print(job_title.text.split('\n')[0])
    driver.implicitly_wait(random_number)
    time.sleep(random_number)

    left_rail = driver.find_element_by_css_selector('.jobs-search__left-rail')
    driver.implicitly_wait(random_number)
    time.sleep(random_number)
    left_rail.send_keys(Keys.PAGE_DOWN)

This is the code I am using and it works. I tried with youtube and when I sleect the body or html as the tag then I can scroll( even works on linkedin when the screen is not maximized because then the screen wont be divided.

However once it is divided it doesnt work. I tried to grab every possible element but no success so far. The only element that is intractable is the jobs-search__left-rail class( see on the pic below. However once I pick this item it doesnt scroll. enter image description here

Big thanks in advance!



Solution 1:[1]

It seems to me when using Chrome the left element that requires scrolling can be controlled the same way as the whole window (also when I open LinkedIn via Safari the page is not divided and the main scroller of the window controls the left side).

So after identifying the list of selenium elements - jobs_list

jobs_block= driver.find_element(By.CSS_SELECTOR, '.jobs-search-results__list')
jobs_list= jobs_block.find_elements(By.CSS_SELECTOR, '.jobs-search-results__list-item')

I iterated through the list using .execute_script to reveal new elements

n = 0
for i in jobs_list:
    print("__________")
    n+=1
    driver.execute_script("arguments[0].scrollIntoView();", jobs_list[n-1])
    print(n, " ",i.text)

It worked for me, hope it works for you and others who seek how to solve this. I am only partially satisfied with this solution as it still doesn't cover how to scroll the right side of the screen.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RZenBridges