Forum Discussion
Check if PowerBI page is loaded (using Selenium)
knyazs wrote:
Hi!
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?
Thanks,
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.
Thanks,
- ddevogel9 years agoFrequent Visitor
knyazs Might Selenium's built-in ImplicitWait help to solve your problem?
http://www.seleniumhq.org/docs/04_webdriver_advanced.jsp
- knyazs9 years agoRegular Visitor
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 :)
- ekeijl9 years agoHelper I
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):
// HTML <div powerbi-type="report" powerbi-report-id="5dac7a4a-4452-46b3-99f6-a25915e0fe55" powerbi-embed-url="https://app.powerbi.com/reportEmbed" ></div> // JS var embedConfiguration = { type: 'report', id: '5dac7a4a-4452-46b3-99f6-a25915e0fe55', embedUrl: 'https://app.powerbi.com/reportEmbed' }; 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. $('#reportContainer').addClass('done-loading'); });