Make JavaScript code (with selenium) survive the page reload

I am working on a macro recording and playback system with seleniumand JavaScript. At some point, I run JavaScript code that basically subscribes a new even handler to all events windowand provides localStoragesome data about events that I later collect. The problem is that when the user clicks the link or for some other reason the page reloads, event handlers are lost. All data is still in localStorage, but I cannot continue to collect new data.

I have no control over the server, so I can’t paste the code into the page source. I can only control the browser using selenium, so all I can do is execute some JavaScript at some point to start dumping events, as well as some JavaScript at a later stage to recover the event data. User can view StackOverflow what I know.

Is there a workaround?

PS: I use selenium for pythonif that matters.

+4
source share
2 answers

-, squid, ICAP *, , . , , javascript.

Squid 3 ICAP- .

* -, RFC 3507

+1

, :

, Gatejs SPDY/HTTP proxy gatejs - , .

Gatejs html- HTML (text/html).

- .

var serverConfig = function(bs) { return({
    hostname: "testServer0",
    runDir: "/tmp/gatejs",
    dataDir: "/path/to/dataDir",
    logDir: "/var/log/gatejs",

    http: {
        testInterface: {
            type: 'forward',
            port: 8080,
            pipeline: 'pipetest'
        },
    },
    pipeline: {
        pipetest: [
            ['injection', {
                 code: "<h1>w00t injection</h1>"
            }],
            ['proxyPass', { mode: 'host', timeout: 10 }]
        ],
    }
})};

-

0

Source: https://habr.com/ru/post/1532223/


All Articles