Raymond van zonneveld
Raymond van zonneveld

Reputation: 131

Clicking Div element : stale element reference

I am trying to click a button.

The button has a div element with id ctl00_ContentPlaceHolder1_ReportViewer1_ReportViewer

When clicking on the button a dropdown menu should appear where you can select a download option. I want to be able to click the excel download option.

To click the first button i tried clicking the button by doing

click_download_button = driver.find_element_by_xpath('//div[@id="ctl00_ContentPlaceHolder1_ReportViewer1_ctl10_ctl04_ctl00"]')
click_download_button.click()

However, i get the stale element reference.

I also tried hovering over the button andthen clicking, but this also did not seem to work.

I also tried directly clicking on the second button (an excel download button).

The download button has the following attributes

<a class="ActiveLink" title="Excel" alt="Excel" onclick="$find('ctl00_ContentPlaceHolder1_ReportViewer1').exportReport('EXCELOPENXML');" href="javascript:void(0)" style="padding:8px 8px 3px 8px;display:block;white-space:nowrap;text-decoration:none;">Excel</a>

I tried this by finding the button based on the title "Excel" but this also did not work

Any way to be able to click the first button or directly click the download button?

Upvotes: 0

Views: 43

Answers (1)

Hush
Hush

Reputation: 44

do u tried:

import time

time.sleep(1)

click_download_button = driver.find_element_by_id("ctl00_ContentPlaceHolder1_ReportViewer1_ctl10_ctl04_ctl00")

click_download_button.click()

Upvotes: 1

Related Questions