Validating that page assets are cached
It’s not just HTML elements that need to be tested, and sometimes not even testing that images or CSS files are being tested. Sometimes you need to test things like server configurations. Magium’s position is that there are a wealth of different areas where browser testing can benefit your organization. Validating browser testing configurations is is one such example.
In this example you can test to make sure that the browser cache is set properly.
use Magium\AbstractTestCase;
use Magium\Assertions\Browser\AssetIsCached;
class AssetCacheTest extends AbstractTestCase
{
public function testCache()
{
$this->commandOpen('http://magento.magiumlib.com/');
$this->webdriver->byCssSelector('a.logo')->click();
$assertion = $this->getAssertion(AssetIsCached::ASSERTION);
/* @var $assertion AssetIsCached */
$assertion->setAssetUrl('/skin/frontend/rwd/default/images/media/logo.png');
$assertion->assert();
}
}
Note The mechanism for this test is somewhat new in the browser world and maybe be configuration dependent on the browser.