Skip to main content
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Regular Visitor

Check if PowerBI page is loaded (using Selenium)



I am using Selenium to automate load and performance testing of PowerBI reports and I need a reliable way to pause code execution until page is fully loaded (all queries executed and all slicers and charts displayed). Many pages on Google suggested I should use following JavaScripts codes to achieve that:

  • return == 0
  • return document.readyState == "complete"

But this does not work for me as both lines are always verified as true and code continues executing although I can see that chart has not been drawn.


The only way I could made it work is to get XPaths of all elements from the report (slicers, charts, etc.) and wait for all of those elements to "become"visible:


public void waitUntilReportProcesses(IWebDriver driver)
	WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(600.00));
	var xpaths = new string[]
		"//*[@id=\"pvExplorationHost\"]/div/div/div/div[1]/div[2]/div[3]/div[2]/div[2]", // chart 1
		"//*[@id=\"pvExplorationHost\"]/div/div/div/div[1]/div[2]/div[9]/div[2]/div[2]", // chart 2
		"//*[@id=\"pvExplorationHost\"]/div/div/div/div[1]/div[2]/div[6]/div[2]/div" // slicer 1

	foreach (var xpath in xpaths)


I tried to make above code more universal by finding elements using css (By.CssSelector). With that approach I am able to get all of the necessary elemets but ElementIsVisible and VisibilityOfAllElementsLocatedBy methods seems to behave differently in that case and code never pauses execution.


What would be the proper way to check if PowerBI page has been loaded?



Frequent Visitor

Hey Did you get the solution to your problem?Can you provide me the code sample ? I want to create a tool to capture the Page Load Time of a Power BI Report. Can you help me with the approach I need to follow?

Unfortunately, I cannot share code with you but I can tell you how I solved it - using Selenium I managed to make it work by "catching" so-called "spinning wheel" or "wait" sign on the page after slicer is clicked. I would start measuring time from slicer click and then wait few seconds to see if "wait" sign appears and disappears - it there is no wait sign after few seconds, I would take time captured immediately after slicer click; if "wait" appeared, I would wait until it disappears and capture timestamp.


I hope this helps.

I know you cannot share your code, but an example of your code with dummy names would be good to understand how you were able to use the spin wheel. Did you get this from another example on the web?

Not applicable



I am doing similar thing in selenium with PBI report. Can you share how did you get the hold of wait symbol or element in the report.




Helper I
Helper I

The new JavaScript API allows you to listen to the event that indicates that the report is done loading:


I'm not sure whether you could use this directly in your test. A different approach could be to listen for the 'loaded' event in your application code and then make some changes to the DOM in your application (something that can be detected by Selenium) that flags the report as 'finished loading'.


Just an idea, hope this helps 🙂


@knyazs wrote:



I am using Selenium to automate load and performance testing of PowerBI reports and I need a reliable way to pause code execution until page is fully loaded (all queries executed and all slicers and charts displayed). Many pages on Google


What would be the proper way to check if PowerBI page has been loaded?







I don't have much expertise on javascript so I have no idea on how to capture the page loading accomplished in JS.


However, as per the knowledge in my previous job, to test the page loading performance, a more accurate way would be tracing the network traffic. And based on my test, regarding an embeded report, the loading span is between the first embeded url request and the last "querydata" request. See below snapshot captured in F12 in firefox. So you may consider to use Wireshark or Fiddler.


Hi Eric,


Thanks for the quick reply. Fiddler is a great tool but I don't think I can use it in this case.


Just to be absolutely clear on this matter, let me explain what I'm doing - I created C# project which uses Selenium to simulate user clicks on PowerBI report slicers. After slicer is clicked, page will start refreshing but Selenium cannot automatically detect when load is over as PowerBI (I assume) uses ajax / json / jquery. If page is not completely loaded and code continues with the execution (next slicer click) an attempt to click on non-existing / non-visible / non-clickable / ... element may occur and code will throw an error. Also, adding a delay after slicer click is not an option as I am trying to test how quick report is.



@ddevogel Yes, I am currently using that mechanism (check code sample in my first post) and it works fine. The issue is that XPaths need to be taken for each element of each report and if report changes, code needs to be changed as well.


I was just wondering if there is something "universal" for PowerBI pages, such as some flag or tag on the page which I could reuse across muliple reports?


@ekeijl Sounds promissing. As I only know basics of JavaScript / Web Dev, code sample of this approach would mean a lot 🙂

There are quite some code samples on the Github wiki, I suggest you check them out.


It would look something like this (combined this and this😞




// JS
var embedConfiguration = {
    type: 'report',
    id: '5dac7a4a-4452-46b3-99f6-a25915e0fe55',
    embedUrl: ''
var $reportContainer = $('#reportContainer');
var report = powerbi.embed($reportContainer.get(0), embedConfiguration);

// Here we listen for the loaded event
report.on('loaded', event => {
    // Here the reports are loaded, do something that can be detected by Selenium.


@ekeijl powerbi-type, powerbi-report-id and powerbi-embed-url are properties that don't exist in the report until you embed report somewhere else - that is when report gets id as well.


I wouldn't want to embed PowerBI report, I just need to find some existing element (document, window or something third) to attach to and inject or execute JS to check if page is loaded.

Helpful resources

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors