Selenium-Debugging: Element is not clickable at point (X,Y)

前端 未结 5 1062
傲寒
傲寒 2020-11-30 19:38

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\').c         


        
相关标签:
5条回答
  • 2020-11-30 20:09

    Use explicit wait instead of implicit.

     new WebDriverWait(TestingSession.Browser.WebDriver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementExists((By.ClassName("pagination-r'")))); 
    
    0 讨论(0)
  • 2020-11-30 20:11

    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)
    
    0 讨论(0)
  • 2020-11-30 20:11

    I have written logic to handle these type of exception .

       def find_element_click(self, by, expression, search_window=None, timeout=32, ignore_exception=None,
                           poll_frequency=4):
        """It find the element and click then  handle all type of exception during click
    
        :param poll_frequency:
        :param by:
        :param expression:
        :param timeout:
        :param ignore_exception:list It is a list of exception which is need to ignore.
        :return:
        """
        if ignore_exception is None:
            ignore_exception = []
    
        ignore_exception.append(NoSuchElementException)
        if search_window is None:
            search_window = self.driver
    
        end_time = time.time() + timeout
        while True:
            try:
                web_element = search_window.find_element(by=by, value=expression)
                web_element.click()
                return True
            except tuple(ignore_exception) as e:
                self.logger.debug(str(e))
                if time.time() > end_time:
                    self.logger.exception(e)
                    time.sleep(poll_frequency)
                    break
            except Exception as e:
                raise
        return False
    
    0 讨论(0)
  • 2020-11-30 20:21

    If you are receiving an element not clickable error, even after using wait on the element, try one of these workarounds:

    • Use Action to move to the location of element and then run perform on action
    WebElement element = driver.findElement(By("element_path"));
    Actions actions = new Actions(driver);
    actions.moveToElement(element).click().perform();`
    
    • Check for an overlay or spinner on the element and wait for its invisibility
    By spinnerimg = By.id("spinner ID");
    WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
    wait.until(ExpectedConditions.invisibilityOfElementLocated(spinnerimg ));
    

    Hope this helps

    0 讨论(0)
  • 2020-11-30 20:25

    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
    
    0 讨论(0)
提交回复
热议问题