How to clear Browser cache on an Android device?
If you attempt to select the ClearCache() method when recording against a browser application running on a mobile Android device; the following error will be reported, as ClearCache() is currently not supported for mobile browsers:
This may present a problem if a web application under test caches user data, which must be removed before further tests will playback successfully.
Currently the only option to remove the cached data is to automate the actions required to manually clear the browser cache; it is recommended that these steps are encapsulated in a function that can be called either before or after of test, to prepare the browser for further testing.
In the Workbench we recommend keeping the function in a separate script; where it can be called from any script that contains a reference to the script where it resides:
In this client we recommend that the ClearBrowserCache() is called from within the method declared with the @After JUnit annotation; as such methods are guaranteed to run even if the @Before or @Test method were to throw an exception:
In Silk4Net the recommended approach is to call the ClearCache() method from within a function defined with the <TestCleanup>; as it guarantees that cache cleanup take place whether an exception is thrown or not.