現在、seleniumでpage移動の自動化をしようとしています。
あるウェブサイト(下にリンクを貼ります)を参考に作成しているのですがうまく行きません。
原因わかる方どなたかご教授よろしくお願いします。
python
1""" 2page移動を試す 3""" 4from time import sleep, strftime, gmtime, time 5from selenium import webdriver 6from selenium.webdriver.chrome.options import Options 7from selenium.webdriver.common.action_chains import ActionChains 8from selenium.webdriver.common.keys import Keys 9 10from selenium.webdriver.support.ui import WebDriverWait 11from selenium.webdriver.support import expected_conditions as EC 12from selenium.webdriver.common.by import By 13 14 15 16driver = webdriver.Chrome("") 17 18options = Options() 19options.add_argument('--headless') 20 21 22driver.get("http://localhost/Myapp") 23 24def get_NextPage(driver): 25 ''' 26 次のページに遷移する 27 FIXME:for文でページを1pageずつ持ってくるようにする 28 ------ 29 class="next_page disabled"まで要素を持ってくるようにする 30 ''' 31 try: 32 wait = WebDriverWait(driver,50) 33 34 wait.until(EC.element_to_be_clickable((By.CLASS_NAME,"next_page"))) 35 element = driver.find_element_by_class_name("next_page") 36 while EC.element_to_be_clickable((By.CLASS_NAME,"next_page")): 37 element.click() 38 print('クリックするまで待ってます') 39 40 if not element.is_enabled(): 41 print('ページ要素のクリック終了しました') 42 break 43 finally: 44 driver.quit() 45 46 47get_NextPage(driver)
1ページ分は移動するのですがそれからが移動しないです。どなたかご教授ください
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/11 03:04
2019/07/11 03:27
2019/07/12 15:23
2019/07/17 02:46