0

I am automate a login and download data process. At my final step: click 'export' then download .csv file. I faced the error:

selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document (Session info: chrome=86.0.4240.111)

I tried lots of way as below, but I cannot fix it. '''

driver.find_element_by_xpath('...').click()
driver.find_element_by_xpath('...').click()
driver.find_element_by_css_selector('...').click()

options = Options()
options.add_experimental_option("prefs", {
  "download.default_directory": r"C:\Users\yhu\Downloads",
  "download.prompt_for_download": False,
  "download.directory_upgrade": True,
  "safebrowsing.enabled": True
})

Specific HTML element:

<a onclick="return onGridExport(this);" id="ctl00_ctl39_g_c2f29a2f_3d77_43a2_b3ae_ad4098b04506_GridExport" tabindex="43" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ctl39$g_c2f29a2f_3d77_43a2_b3ae_ad4098b04506$GridExport&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))">Export</a>
Rainie
  • 1

0 Answers0