How to clear browser cache in Selenium test

前端 未结 3 1736
遇见更好的自我
遇见更好的自我 2021-01-02 01:40

I am running my Selenium tests with WebDriver. I am repeating the tests with some loop so now I want to Clear the cache before starting new test in JAVA.

@Te         


        
相关标签:
3条回答
  • 2021-01-02 02:09

    Currently, there is no way to clear the cache through the web driver API. However, if you can start a new instance of the browser each time, the cache should be cleared in FF and Chrome because a new profile is created on each launch.

    The comments for issue #40 (Clear cache) in the Selenium issue tracker list two potential solutions to your problem if creating a new browser instance isn't possible:

    1. Clear the IE cache from the command line
    2. Disable the FF cache using a custom profile

    HTH

    0 讨论(0)
  • 2021-01-02 02:18

    DT_IE_AGENT_ACTIVE=true activates the Add-On so that it collects data from the current browser session

    Hope it help

    0 讨论(0)
  • 2021-01-02 02:32

    I have used this lines of code in python to do that and it seems to clear the cache every time(Internet Explorer)

    capab = DesiredCapabilities.INTERNETEXPLORER

    capab.clear()

    0 讨论(0)
提交回复
热议问题