2017-03-24 118 views
1

我想移動到頁面2和本頁面(分頁)與蟒蛇硒,並花了幾個小時就此。我得到這個錯誤,並且將感謝任何help..Error從chromedriver無法點擊網頁上的元素硒python

is not clickable at point(). Other element would receive the click 

到目前爲止我的代碼:

class Chezacash: 
    t1 = time.time() 
    driver = webdriver.Chrome(chromedriver) 


    def controller(self): 
     self.driver.get("https://www.chezacash.com/#/home/") 
     element = WebDriverWait(self.driver, 10).until(
     EC.presence_of_element_located((By.CSS_SELECTOR, "div.panel-heading")))  
     soup = BeautifulSoup(self.driver.page_source.encode('utf-8'),"html.parser") 
     self.parser(soup) 
     self.driver.find_element(By.XPATH, "//li[@class='paginate_button active']/following-sibling::li").click() 
     time.sleep(2) 
     soup = BeautifulSoup(self.driver.page_source.encode('utf-8'),"html.parser") 
     self.parser(soup) 


    def parser(self, soup): 
     for i in soup.find("table", {"id":"DataTables_Table_1"}).tbody.contents: 
      date = i.findAll("td")[0].get_text().strip() 
      time = i.findAll("td")[1].get_text().strip() 
      home = i.findAll("td")[4].div.span.get_text().strip().encode("utf-8") 
      home_odds = i.findAll("td")[4].div.findAll("span")[1].get_text().strip() 
      draw_odds = i.findAll("td")[5].div.findAll("span")[1].get_text().strip() 
      away = i.findAll("td")[6].div.span.get_text().strip().encode("utf-8") 
      away_odds = i.findAll("td")[6].div.findAll("span")[1].get_text().strip() 
      print home 

cheza = Chezacash() 
try: 
    cheza.controller() 
except: 
    cheza.driver.service.process.send_signal(signal.SIGTERM) # kill the specific phantomjs child proc       # quit the node proc 
    cheza.driver.quit() 
    traceback.print_exc() 
+1

快速評論您的代碼。在'for i'循環中,第一行應該將'i.findAll(「td」)'存儲在變量中,然後'date'等等將訪問不同的[[0]'等元素。您當前的代碼正在爲每個分配的變量重新打印頁面('.findAll()')。 – JeffC

回答

2

如果相反,你會被找到「下一步」按鈕鏈接文本,滾動到它的視圖,然後單擊:

next_button = self.driver.find_element_by_link_text("Next") 
self.driver.execute_script("arguments[0].scrollIntoView();", next_button) 
next_button.click() 

我還要導航到頁面之前瀏覽器窗口最大化:

self.driver.maximize_window() 
self.driver.get("https://www.chezacash.com/#/home/") 
+0

Worked ..cheers mate .. –