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
- make sure full screen is orange and safely remove the div - baby steps to fix https://github.com/sitespeedio/sitespeed.io/issues/2091 — committed to sitespeedio/browsertime by soulgalore 6 years ago
- catch navigation within the page https://github.com/sitespeedio/sitespeed.io/issues/2091 — committed to sitespeedio/chrome-har by soulgalore 6 years ago
- Navigate within document (#28) * catch navigation within the page https://github.com/sitespeedio/sitespeed.io/issues/2091 * correct title for navigating within document — committed to sitespeedio/chrome-har by soulgalore 6 years ago
- Smarter way to take care of orange layer for video (#648) There are three fixes: make sure the layer of orange is full screen, remove the layer instead of making it white and make sure visual metrics... — committed to sitespeedio/browsertime by soulgalore 6 years ago
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:
I’ve added a meta task (#2094) for tracking what we need to fix.