问题
I try to scrape this site by Selenium.
I want to click in "Next Page" buttom, for this I do:
driver.find_element_by_class_name('pagination-r').click()
it works for many pages but not for all, I got this error
WebDriverException: Message: Element is not clickable at point (918, 13). Other element would receive the click: <div class="linkAuchan"></div>
always for this page
I read this question
and I tried this
driver.implicitly_wait(10)
el = driver.find_element_by_class_name('pagination-r')
action = webdriver.common.action_chains.ActionChains(driver)
action.move_to_element_with_offset(el, 918, 13)
action.click()
action.perform()
but I got the same error
回答1:
Another element is covering the element you are trying to click. You could use execute_script()
to click on this.
element = driver.find_element_by_class_name('pagination-r')
driver.execute_script("arguments[0].click();", element)
回答2:
I had a similar issue where using ActionChains was not solving my error: WebDriverException: Message: unknown error: Element is not clickable at point (5 74, 892)
I found a nice solution if you dont want to use execute_script:
from selenium.webdriver.common.keys import Keys #need to send keystrokes
inputElement = self.driver.find_element_by_name('checkout')
inputElement.send_keys("\n") #send enter for links, buttons
or
inputElement.send_keys(Keys.SPACE) #for checkbox etc
回答3:
Use explicit wait instead of implicit.
new WebDriverWait(TestingSession.Browser.WebDriver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementExists((By.ClassName("pagination-r'"))));
来源:https://stackoverflow.com/questions/37879010/selenium-debugging-element-is-not-clickable-at-point-x-y