Selenium WebDriver script for exporting data from Power BI dashboard encountering errors

I’m trying to automate the process of exporting data from a table in a Power BI dashboard using Selenium WebDriver and encountering some issues. Here’s a summary of what I’m trying to achieve and the problems I’m facing:

Objective:

  • Navigate to a specific Power BI dashboard URL.
  • Locate a table within the dashboard.
  • Click on the “more options” button (represented by a “…”) next to the table.
  • Click on the “Export data” option that appears.
  • Handle any dialog or modal that appears after clicking “Export data”.
  • Click the final “Export” button to initiate the download.
  • Verify if the exported file (exported_data.csv) exists in the Downloads folder.

Current Issues:
I’ve implemented the script using Python and Selenium WebDriver for Microsoft Edge.
The script fails consistently with an error message that doesn’t provide clear guidance on what’s wrong.
ERROR:__main__:Error occurred: Message: Stacktrace: GetHandleVerifier [0x00007FF776C08132+13538] Microsoft::Applications::Events::EventProperty::~EventProperty [0x00007FF776B91DE9+595465] (No symbol) [0x00007FF7769AE6CF] (No symbol) [0x00007FF7769F2960] (No symbol) [0x00007FF7769F2A1F] (No symbol) [0x00007FF776A2D627] (No symbol) [0x00007FF776A1203F] (No symbol) [0x00007FF7769E8147] (No symbol) [0x00007FF776A2B1EE] (No symbol) [0x00007FF776A11C63] (No symbol) [0x00007FF7769E766E] (No symbol) [0x00007FF7769E683C] (No symbol) [0x00007FF7769E7221] Microsoft::Applications::Events::EventProperty::to_string [0x00007FF776DC96D4+1099860] Microsoft::Applications::Events::EventProperty::~EventProperty [0x00007FF776B0D8FC+53532] Microsoft::Applications::Events::EventProperty::~EventProperty [0x00007FF776B00E25+1605] Microsoft::Applications::Events::EventProperty::to_string [0x00007FF776DC8665+1095653] Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF776B9C961+27777] Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF776B96CE4+4100] Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF776B96E1B+4411] Microsoft::Applications::Events::EventProperty::~EventProperty [0x00007FF776B8CFA0+575424] BaseThreadInitThunk [0x00007FF82639257D+29] RtlUserThreadStart [0x00007FF82660AF28+40]

My code:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import os
import time
import logging

# Setup logging
logging.basicConfig(level=logging.INFO)  # Set logging level to INFO
logger = logging.getLogger(__name__)

# Initialize the WebDriver (using Microsoft Edge in this example)
driver = webdriver.Edge()

try:
    # Open the Power BI dashboard
    driver.get("https://app.powerbi.com/groups/me/apps/abcdwd-dddddd2-4dc0-9a2e-e3a701c76f0b/reports/.......")

    # Wait for the dashboard to load
    WebDriverWait(driver, 60).until(EC.presence_of_element_located((By.ID, "reportContainer")))

    # Locate the table within the dashboard using the provided class
    table_locator = (By.CSS_SELECTOR, 'div.visualWrapper.report')
    table_element = WebDriverWait(driver, 30).until(EC.presence_of_element_located(table_locator))

    # Find the "more options" button next to the table and click it
    more_options_button_locator = (By.CSS_SELECTOR, 'button[data-testid="visual-more-options-btn"]')
    more_options_button = table_element.find_element(*more_options_button_locator)
    more_options_button.click()

    # Wait for the "Export data" option to appear and click it
    export_data_locator = (By.CSS_SELECTOR, 'button[data-testid="pbimenu-item.Export data"]')
    export_data_button = WebDriverWait(driver, 30).until(EC.element_to_be_clickable(export_data_locator))
    export_data_button.click()

    # Now handle the dialog/modal that appears after clicking "Export data"
    # Assuming there's no iframe switch needed, adjust if necessary

    # Wait for the final "Export" button and click it
    final_export_locator = (By.CSS_SELECTOR, 'button[data-testid="export-btn"]')
    final_export_button = WebDriverWait(driver, 30).until(EC.element_to_be_clickable(final_export_locator))
    final_export_button.click()

    # Wait for some time to allow the export process to complete (adjust as needed)
    time.sleep(10)

    # Example: Check if the exported file exists in the downloads folder
    download_path = os.path.expanduser('~\Downloads')  # Adjust for different OS if necessary
    exported_file = os.path.join(download_path, 'exported_data.csv')

    if os.path.exists(exported_file):
        logger.info("Exported file found at: %s", exported_file)
    else:
        logger.error("Exported file not found. Check export process or download manually.")

except Exception as e:
    logger.error(f"Error occurred: {str(e)}")

finally:
    # Close the WebDriver
    driver.quit()


New contributor

Nhu Tuyen Nguyen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật