retaining cache in firefox and chrome browser - Selenium WebDriver

后端 未结 2 1236
无人及你
无人及你 2020-12-17 15:04

Currently our web application takes around 3 mins to load completely without caching and 10 secs with caching. When I open the app through WebDriver its taking around 3 mins

相关标签:
2条回答
  • 2020-12-17 15:13

    The problem is, that selenium copies every startup a new (firefox/chrome) profile to the temp directory and starts firefox/chrome with it. However, it is possible to always use the same profile for your test instances. I think this way you can get it working faster.

    For firefox you just need to do these steps:
    1. Load your webapp in a selenium firefox instance and don't close it afterwards (not driver.close();).
    2. Then go to Help->Troubleshooting Information and open the folder under Profile folder.
    3. Copy its content to a new folder near your test code.
    4. Load the saved Profile in your test code. You can do it this way:

    FirefoxProfile profile = new FirefoxProfile(new File("profile/folder/path"));                  
    WebDriver driver = new FirefoxDriver(profile); 
    

    I think you can do this in chrome analogous.

    0 讨论(0)
  • 2020-12-17 15:27

    @CacheLookup annotations can be very useful for the elements that do not change on the web page once loaded. These types of elements constitute a majority of elements on the web page. So for those elements, as they will not change during test execution, you should use the @Cachelookup annotation to improve the test speed.

    Try below codes:

    @FindBy(name="username")
    @CacheLookup
    private WebElement userName;
    
    0 讨论(0)
提交回复
热议问题