2

This is piece if my code:

x=driver.find_element_by_xpath("""//*[@id="react-root"]/section/main/article/div[1]/div/div/div[1]/div[2]/a""")
x.click()

But, this error are occurred:

selenium.common.exceptions.ElementNotInteractableException: Message: Element <a href="/p/BgEcF34Fqf6/?tagged=fast"> could not be scrolled into view

Could you help me, please?

Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
Hamed Baziyad
  • 1,954
  • 5
  • 27
  • 40

2 Answers2

6

Try JavaScript click:

from selenium.webdriver.remote.webelement import WebElement


def javascript_click(self, locator):
    element = None
    if isinstance(locator, str):
        element = self.find_element(locator)
    elif isinstance(locator, WebElement):
        element = locator

    if element is not None:
        self._driver.execute_script("arguments[0].click();", element)
    else:
        raise Exception("Could not click on locator " + element)
colin-zhou
  • 185
  • 1
  • 15
GirishB
  • 524
  • 1
  • 3
  • 9
0

I used this code which was worked carefully:

#Scroll down the page to load more posts
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    time.sleep(10)
    j=j+1

Note that, you can generalize this scrolling into more that one reputation by use of for syntax.

Hamed Baziyad
  • 1,954
  • 5
  • 27
  • 40