1. 程式人生 > >Python3 - Selenium: Element is not currently visible and may not be manipulated

Python3 - Selenium: Element is not currently visible and may not be manipulated

Element is not currently visible and may not be manipulated

 

def click_next(self):
    try:
        self.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
        self.driver.find_element_by_xpath('//li[@class="paging-item"]/a').click()
    except:
        raise
        return False

處理方式如下: browser.set_window_size(1920, 1080)  # choose a resolution big enough

from selenium import webdriver

url = 'http://www.sreality.cz/hledani/prodej/byty/praha-2,praha-3?stavba=cihlova&vlastnictvi=osobni&strana=1'

browser = webdriver.PhantomJS()
browser.set_window_size(1920, 1080)  # choose a resolution big enough
browser.get(url)

next_arrow = browser.find_element_by_class_name('paging-next')
next_arrow.click()