Hi there,
I am writing a new test for localStorage testing. To do so, I need to swipe the localstorage set it via Siesta and afterwards run the app.
I did not find another way than to use window.location.href and waitForPageLoad.
But after loading the page I need to reference everything via window (that goes for localStorage as well as for the App).
Is there a way around or did I miss something?
Best regards
Kurt
Support Forum
The window object of the new page is available as the first param of your callback, see docs here: https://www.bryntum.com/docs/siesta/#!/a ... orPageLoad
I know, that's what i am doing at the moment.
But after loading the new page i need to do all calls with window at the beginning.
E.g.
Inside appLoaded I access quite some window items.
As you can see I can access the localstorage at the beginning without the use of "window." , which I would prefer.
Is there a way to get to this?
But after loading the new page i need to do all calls with window at the beginning.
E.g.
StartTest(function (t) {
localStorage.clear();
t.is(localStorage.length, 0, 'LocalStorage is cleared');
t.diag("Load App");
window.location.href = "index.html";
t.waitForPageLoad(function (window) {
appLoaded(t, window);
});
function appLoaded(t, window) {
t.diag("localStorage length: " + window.localStorage.length);
t.done();
}
});
As you can see I can access the localstorage at the beginning without the use of "window." , which I would prefer.
Is there a way to get to this?
Just save a ref to it in the outer scope:
StartTest(function (t) {
localStorage.clear();
var outerLocal = localStorage;
t.is(localStorage.length, 0, 'LocalStorage is cleared');
t.diag("Load App");
window.location.href = "index.html";
t.waitForPageLoad(function (window) {
appLoaded(t, window);
});
function appLoaded(t, window) {
t.diag("localStorage length: " + window.localStorage.length);
t.done();
}
});
I guess you can also do
at any time.
var localStorage = window.localStorage
Read the API documentation