I am new to python and I trying to scrape all the recent activity of a Linkedin user for the past 6 months . The code below works fine when there is no video liked by the user. If there is a video, then I get ElementClickInterceptedException error. Could you please suggest a solution for this?
Code:
for elem in driver.find_elements_by_xpath('.//a/div/span/span[@class = "visually-hidden"]|.//a/div/span/span/span[@class = "visually-hidden"]'):
if elem.text == "7 months ago":
break
else:
print(elem.text)
try:
print ("in try")
button["key%s" %i] = WebDriverWait(driver, 30).until(expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='main']/div/div[2]/div/span/button[@class='artdeco-button artdeco-button--muted artdeco-button--1 artdeco-button--full artdeco-button--secondary ember-view']")))
hover = ActionChains(driver).move_to_element(button.get("key%s" %i))
hover.perform()
button.get("key%s" %i).click()
i = i+1
except exceptions.StaleElementReferenceException as e:
element = driver.find_element_by_xpath("//*[@id='main']/div/div[2]/div/span/button[@class='artdeco-button artdeco-button--muted artdeco-button--1 artdeco-button--full artdeco-button--secondary ember-view']")
driver.execute_script("arguments[0].click();", element)
print(e)
This is the error displayed:
ElementClickInterceptedException at /login/
Message: element click intercepted: Element <button tabindex="-1" id="ember631" class="artdeco-button artdeco-button--muted artdeco-button--1 artdeco-button--full artdeco-button--secondary ember-view" type="button">...</button> is not clickable at point (249, 547). Other element would receive the click: <img width="600" src="https://media-exp1.licdn.com/dms/image/C4E22AQHboa3Imyqsew/feedshare-shrink_800/0/1619094377786?e=1622678400&v=beta&t=oa-7gYnDMsfdopCC30LWGu4sv2R8TLPN6drB_Q5IQME" loading="lazy" height="750" alt="No alternative text description for this image" id="ember902" class="ivm-view-attr__img--centered feed-shared-image__image feed-shared-image__image--constrained lazy-image ember-view">
Thanks in advance!