scrapinghub / splash

Lightweight, scriptable browser as a service with an HTTP API
BSD 3-Clause "New" or "Revised" License
4.04k stars 507 forks source link

Failed loading page (Frame load interrupted by policy change) #1148

Open lime-n opened 2 years ago

lime-n commented 2 years ago

I'm having the following error :

Failed loading page (Frame load interrupted by policy change)

produced as a PNG image from my lua script when trying to grab the content of a document. It provides the link to the document in the image instead, rather than loading the content.

Here's some reproducible code:

url = https://orion.lancaster.ne.gov/Property-Detail/PropertyQuickRefID/R110893/PartyQuickRefID/O16011
function main(splash)
    assert(splash:go(splash.args.url))
    local get_dimensions = splash:jsfunc([[
        function () {
            var rect = document.querySelector('a[id="btnDataSheet"] i[class="fa fa-file-pdf-o fa-2x"]').getClientRects()[0];
            return {"x": rect.left, "y": rect.top}
        }
    ]])
    splash:set_viewport_full()
    splash:wait(3)
    local dimensions = get_dimensions()
    -- FIXME: button must be inside a viewport
    splash:mouse_click(dimensions.x, dimensions.y)

    -- Wait split second to allow event to propagate.
    splash:wait(5)
    return splash:png()
end