1

I'm trying to scroll a website to click on follow buttons, each time I run my code it will follow the first 4 people and then run into an error.

my code is

''' def follow():

driver.implicitly_wait(30)  
counter = 1  
        

#create base x path to alow us to add 4 each time
base_xpath = '//*[@id="react-root"]/div/section/div[3]/div/div/div[3]/div/div[3]/main/div[1]/div[2]/ul/li['

for i in range(4, 80000, 4): # skipping by 4 each time up to 80000 starting at 4
  xpath = base_xpath + str(i) + ']/button/span'

  scrollTarget = driver.find_element_by_xpath(xpath)
 
  driver.execute_script('arguments[0].scrollIntoView()', scrollTarget)
  print("scrolling")
  sleep(5)
  try:
    for i in range(4):
        driver.implicitly_wait(25)
        elem = driver.find_element_by_xpath('//*[text()="Follow"]')
        elem.click()
        counter = counter + 1
        print("we followed someone " + str(counter))
  
  except NoSuchElementException:
       pass  
    #sleep(15)
    
    

'''

the error is

Traceback (most recent call last): File "/Users/twiggygarcia/Documents/Coding and Scripts/mixcloud bot/mixcloud bot v1.py", line 94, in follow()
File "/Users/twiggygarcia/Documents/Coding and Scripts/mixcloud bot/mixcloud bot v1.py", line 87, in follow elem.click() File "/Users/twiggygarcia/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click self._execute(Command.CLICK_ELEMENT) File "/Users/twiggygarcia/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute return self._parent.execute(command, params) File "/Users/twiggygarcia/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/Users/twiggygarcia/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element ... is not clickable at point (767, 8). Other element would receive the click: ... (Session info: chrome=96.0.4664.55)

it seems to be related to this line

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element ... is not clickable at point (767, 8). Other element would receive the click:

I would like to avoid the error and keep clicking on the remains buttons

Twiggy Garcia
  • 37
  • 1
  • 7
  • The error says something else will get the click, maybe the button is disabled. If you run the test until the error, open dev tools with F12 and the look for the element using $x("//*[text()='Follow']"). What hets highlighted? Is it disabled or maybe something different than expected? – Taco Verhagen Nov 25 '21 at 06:18

0 Answers0