Waiting for webpage to finish loading - not so easy!

I have a Chrome extension that loads a tab and draws data from a database. I need to have it wait until all the data has been populated onto the tab page. Tried using the Wait For Google Chrome to Finish Loading, but it seemed to ignore that.

Is there another way to do this?

If it helps, there is a part of the loading page that does this…

No of results: 10/40, 20/40…40/40…Then its finished. It could be out of 50 or 100 or whatever. If I could somehow identify that then I could use that as an indicator of it finishing its process.

Any ideas? :smile:

Thanks,

Jon

Waiting for a page to finish loading is always a problematic thing since modern web application never really finish, they are forever chattering with the server.

Probably the best suggestion would be to use some sort of Pause Until Found Image condition to detect the when the window actually says it is finished.

Other than that you would have to delve into the web page to figure out something in the page that changes that you can detect with JavaScript.

I used to think when the Chrome image showing the page was loading was the indicator. In any case, for my extension, that indicator finishes way before the whole page is populated. I think its something to do with the extension dragging data from their database.

Is there a way to scrape html from the page?

The html in this case is:

<div class="header-division header-Results">
<b>Nº of results</b>
 <span class="info">68 <small>/</small> 68</span>
</div>

When the left had number reaches the right hand number the process is completed. So I could continually check the page source in a loop until (in this case) the left hand number reaches 68.

My challenge is…

a) how do get the source html into a variable

b) how to scrape the left and right value for a comparison. Regex I suppose?

Thanks,

Jon

Hey Jon,

Always give as much information as you can. It saves a lot of time and effort.

What extension?

What webpage? (If not confidential.)

Use an Execute a JavaScript in Google Chrome action.

document.body.parentNode.outerHTML

You can use an If Then Else action with text contains for literal text or text matches for a regular expression, and then a Break From Loop action to exit your outer loop.

It might be even easier to do with Xpath looking for the specific element in the page, but I'd have to be able to look at the source myself to know.

-Chris

I just edited my previous post so you can actually see the html. Didn’t realise it stripped it!

The extension is one for an ecommerce site. You have to buy it to get access to it.

The webpage url on a quick test I did: chrome-extension://cdjbejbeejfiepblooifmpefcmobpcde/html/popup.html?st234

Hey Jon,

The Discourse forum software uses Markdown, so it will often eat code unless you put it in a code-block. (You figured out how to do this I see.)

Run this JavaScript on your page and see if you get a useful result:

document.getElementsByClassName('info')[0].outerHTML

Use the Execute a JavaScript in Google Chrome action with the display results in a window option.

-Chris

Hey Jon,

Ah. Even so it's good to know what such a thing is.

It's often possible to get images of items from Google that help visualize an issue.

Hmm. Doesn't look like a valid URL.

-Chris

Unfortunately I cannot name the plugin, else our competitors will be all over this. :smile:

The url I pasted is what gets shown in the url bar in chrome. I think it must create a temp html page locally, as it populates the data via the extension.