0
これは私の最初のWebスクラッププロジェクトで、Webサイト上のいくつかのオプションを選択した後にcsvファイルを動的に生成するためにPythonでSelenium Webdriverを使用していますまだありません)。click()Webdriver Selenium関数Pythonを使用した場合のタイムアウト
しかし、実行がボタンclick()に達すると予期しないタイムアウトに直面しています。クリックは実行されますが、そこに停滞し、タイムアウトまで実行を続行しません。
これを解決する手掛かりはありますか?
ありがとうございます!
from selenium import webdriver
from selenium.webdriver.support.ui import Select
import time
driver = webdriver.Firefox()
driver.get('http://www8.receita.fazenda.gov.br/SimplesNacional/Aplicacoes/ATBHE/estatisticasSinac.app/Default.aspx')
driver.find_element_by_id('ctl00_ctl00_Conteudo_AntesTabela_lnkOptantesPorCNAE').click()
Select(driver.find_element_by_id("ctl00_ctl00_Conteudo_AntesTabela_ddlColuna")).select_by_visible_text("Município")
filtro_uf = driver.find_element_by_id('ctl00_ctl00_Conteudo_AntesTabela_btnFiltros')
for i in range (1, 28):
filtro_uf.click()
uf = Select(driver.find_element_by_id("ctl00_ctl00_Conteudo_AposTabela_ddlUf"))
uf.options[i].click()
time.sleep(2)
driver.find_element_by_id('chkTodosMunicipios').click()
time.sleep(2)
driver.find_element_by_xpath("//*[contains(text(),'Ok')]").click()
time.sleep(2)
# Here is where my code get stuck and gets a timeout
driver.find_element_by_id('ctl00_ctl00_Conteudo_AntesTabela_btnExibir').click()
私が取得エラー:
Traceback (most recent call last):
File "/home/hissashi/Desktop/Python3/WS_SINAC/download_SINAC.py", line 22, in <module> driver.find_element_by_id('ctl00_ctl00_Conteudo_AntesTabela_btnExibir').click()
File "/home/hissashi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "/home/hissashi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webelement.py", line 501, in _execute
return self._parent.execute(command, params)
File "/home/hissashi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 308, in execute
self.error_handler.check_response(response)
File "/home/hissashi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
**selenium.common.exceptions.TimeoutException: Message: Timeout loading page after 300000ms**
'filtro_uf.click()はページをロードしますか? –
一種の「ポップアップウィンドウ」を読み込みますが、最初のページはその後ろに残ります。 –
ポップアップウィンドウでフィルタオプションを選択し、[OK]ボタンをクリックすると、ポップアップが閉じられ、そのメインページが再び表示されます。最後のclick()が実行され、テーブルが完全に生成された後もデータテーブルが表示されますが、ページはまだ読み込まれているかのように保たれますが、そうではありません。そして、次の反復は、ロードがタイムアウトまで続行されるため開始しません。 –