selenium-chrome-clear-cache
🗑 Clear cache of a chrome browser in a Selenium flow
const webdriver = require('selenium-webdriver');
const driver = await new Builder().forBrowser('chrome').build();
const clearCache = require('selenium-chrome-clear-cache');
await driver.get('http://www.website.com/login');
await driver.findElement(By.name('username')).sendKeys('admin');
await driver.findElement(By.name('password')).sendKeys('4dM!n', Key.RETURN);
await driver.wait(until.urlIs('http://www.website.com/'), 1000);
await clearCache({webdriver, driver});
await driver.get('http://www.website.com/');
Uses chrome driver. Get one
Behaviour and Options
The default behaviour clears the cache and history from the last hour. Options can be applied (in form of named arguments) to configure what the browser should clear
name | default |
---|
cookies | false |
cache | true |
history | true |
await clearCache({webdriver, driver}, {cookies: true});
await clearCache({webdriver, driver}, {history: false});
Measuring page performance example