I am new to selenium, and I get the following error: element click intercepted: Element is not clickable at point (774, 8907)
whenever I run this code on the webpage that has the show more button. My goal is to get every element of the "table" on the webpage, but in order to do so I need to click "show more" button if it is present:
driver = webdriver.Chrome(options=chrome_options)
driver.maximize_window()
for el in states_pages:
driver.get(el)
err = False
i = 0
while not err:
try:
more_button = driver.find_element(by=By.CLASS_NAME, value='tpl-showmore-content')
more_button.click()
except selexp.NoSuchElementException as e:
err = True
print(e)
except selexp.ElementClickInterceptedException as e:
err = True
print(e)
i =1
I have tried using javascript executor, waiting until the button is clickable and crolling to the button by using actions, but this didn't work at all.
CodePudding user response:
Try this, it works for me:
show_more_lnk = driver.find_element(By.CSS_SELECTOR, ".tpl-showmore-content")
driver.execute_script("arguments[0].scrollIntoView(true)", show_more_lnk)
time.sleep(2)
show_more_lnk.click()
CodePudding user response:
Because JavaScript interaction. So you have to click using JS execution.
import time
while not err:
try:
more_button = driver.find_element(by=By.CLASS_NAME, value='tpl-showmore-content')
driver.execute_script("arguments[0].click();" ,more_button)
time.sleep(1)
except selexp.NoSuchElementException as e:
err = True
print(e)
except selexp.ElementClickInterceptedException as e:
err = True
print(e)
break