2

I am writing a script for linkedin using selenium python and facing a issue. I want to scroll window of dialog but my script start scrolling window which is at the back.

driver=webdriver.Chrome()
driver.get('https://www.linkedin.com/uas/login?goback=&trk=hb_signin')
driver.find_element_by_name('session_key').send_keys(email)
time.sleep(2)
driver.find_element_by_id('session_password-login').send_keys(password,Keys.RETURN) 
time.sleep(7)
driver.get('https://www.linkedin.com/in/rickblack/skills/(ACoAAAC4aQcBoD2OHCmDN1Fe7n2dMtoVYkWTz4o,27)/')
driver.switch_to.window(driver.window_handles[-1])
for o in range(0,5):
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    time.sleep(1)

Image

1 Answer 1

3

You might try to use below code to define last person in a list and scroll down to it:

the_last_in_list = driver.find_elements_by_xpath('//div[@class="pv-endorsement-entity__detail  pl3')[-1]
the_last_in_list.location_once_scrolled_into_view

P.S. You might need to do this couple times as list of persons initially is not complete: you need to scroll down to trigger XHR to add (load) more persons...

P.P.S. Note, that driver.switch_to.window(driver.window_handles[-1]) makes nothing as there is no new browser windows opened, but just modal window in the same browser window

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your help

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.