sitespeed.io: Prescript does not work properly under hash route

Hello,

I use preScript to complete the login operation, But if the test target switches routes through hash change and login page and test page are in the same domain, the system cannot jump to the test page after running Prescript.

The selenium script is working properly under Sitespeed 6.3.5.

Version: Sitespeed 7.2.0

Docker:

docker run --privileged --shm-size=1g --rm -v "$(pwd)":/sitespeed.io -p 5766:5900 -v /etc/localtime:/etc/localtime:ro sitespeedio/sitespeed.io:7.2.0 'http://xxxxxx' --video --speedIndex --browsertime.preScript ./selenium/tt_login.js --browsertime.chrome.args no-sandbox --browsertime.pageLoadStrategy normal --browsertime.block --plugins.load analysisstorer --browsertime.viewPort "1360x768" -n 1 -b chrome

Selenium script:

module.exports = {
    run(context) {
        return context.runWithDriver(async function(driver){
            const webdriver = context.webdriver;
            const until = webdriver.until;
            const By = webdriver.By;

            // config
            const url = 'http://xxxxxxx';
            const userXpath = '//*[@id="UserName"]';
            const passwordXpath = '//*[@id="Password"]';
            const userName = 'xxxxx';
            const password = 'xxxxx';
            const clickXpath = '//*[@id="Submit"]';

            // run
            async function doLogin(url, userXpath, passwordXpath, clickXpath, userName, password) {
                await driver.get(url);
                await driver.wait(until.elementLocated(By.xpath(userXpath)));
		await driver.wait(until.elementLocated(By.xpath(passwordXpath)));
		await driver.wait(until.elementLocated(By.xpath(clickXpath)));
		await driver.sleep(2000);
                await driver.findElement(By.xpath(userXpath)).sendKeys(userName);
                await driver.findElement(By.xpath(passwordXpath)).sendKeys(password);
                await driver.findElement(By.xpath(clickXpath)).click();
                await driver.sleep(5000);
            }
            await doLogin(url, userXpath, passwordXpath, clickXpath, userName, password)
                .then(_ => console.log('SUCCESS!'), e => console.error('FAILURE: ' + e));
        });
    }
};

Sorry for my bad English.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 31 (19 by maintainers)

Commits related to this issue

Most upvoted comments

Great @Nuoky I’be just released the changes in 7.6.0, hope it works for real this time.

@Nuoky Ok, I think I got a fix now. I’ve changed how we handle how we record the video and changed how we create the HAR from Chrome. I’ve pushed it to a branch in Browsertime, any chance you can try that with your real page so we know that it works before I move the code forward to a new release?

You can test it like this: docker run --shm-size=1g --rm -v "$(pwd)":/browsertime sitespeedio/browsertime-autobuild:better-orange 'https://dvajs.github.io/dva-hackernews/#/show' --preScript ./hackernews.js -n 1 -b chrome --pageCompleteCheckInactivity

I’ve changed when to end the test since there’s no onload event fired in the page when we do the next step. We can do some tuning here to make the “end” better, I need to look more into the code.

Ah sorry I wasn’t being clear plus I was being wrong 😃

What I meant was that before it worked like this:

  • the pre script accessed one URL.
  • then we navigate to the new URL (=writing the URL in the browser window and hit return). That generated a new request and everything work fine. But you tested doing a new navigation.

I’ve added a meta task (#2094) for tracking what we need to fix.