Get help with testing, discuss unit testing strategies etc.


Post by bjones »

I am experiencing some strange behavior when changing URLs in Safari. In our app, clicking on our main logo image re-directs to the main applet by changing the url ( window.location.href = '#'). When automating this with Siesta in Safari, clicking the logo leads to the iframe containing the app to re-direct to the Siesta browser interface instead of the main page. We are using Siesta 5.2.3.

I wrote a workaround to detect the browser we're using and to replace logo clicks with another url re-direct if we're in Safari. This works for now but it would be nice if clicking the logo in Safari did not produce this behavior.

I have included a gif and a reproducible example to produce the issue.

In Chrome - as expected
Image

In Safari
Image

Project
const project = new Siesta.Project.Browser.ExtJS();

project.configure({
    title               : 'Test',
});

project.plan({
    group   : 'Classic Tests',
    items   : [{
		desc	: 'Test url redirect',
		pageUrl : '/siesta/spike.html',
		url	: 'classic-tests/system/new-survey/02_spike.js'
    }]
});

project.start();
spike.html
<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        <h1>
            <span id="clickme" onclick="changeURL()">Click me</span>
        </h1>
        <script>
            function changeURL() {
                window.location.href = '#';
            }
        </script>
    </body>
</html>
Test Case
StartTest(t => {
    t.describe('Test clicking and re-directing to #', t => {
        t.chain({
            waitFor : 2000
        },{
            click : '#clickme'
        });
    });
});

Post by nickolay »

Thank you for the report, confirmed. This strange redirect only happens when the event handler is activated with the synthetic event. If you click the element manually, the same code is executed, but the result is different. Such browser's quirks are beyond Siesta control, we can not fix it, unfortunately.

I noticed you are assigning to the `window.location.href` which is meant for a full page url, shouldn't it be `window.location.hash`? The latter does not trigger this strange redirect.

Post Reply