2017-03-24 8 views
1

私はこのページ(ページネーション)の2ページ目以降を、Pythonセレンで移動しようとしています。私はこのエラーを取得しています、とSelenium pythonの要素をクリックすることができません

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

私のコード今のところchromedriverから任意のhelp..Errorの感謝のようになります。

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

何の代わりに次の方法で「次へ」ボタンを見つけるならばリンクテキストは、それのビューにスクロールして、[OK]をクリックします:

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 .. –

関連する問題