MachinePublishers / jBrowserDriver

A programmable, embeddable web browser driver compatible with the Selenium WebDriver spec -- headless, WebKit-based, pure Java
Other
809 stars 143 forks source link

Most efficient/fastest way to get page views #209

Closed ghost closed 7 years ago

ghost commented 7 years ago

We are architecting a web app and want to stress test it by hitting it with a bunch of page views from JBrowserDriver. What would be the fastest/most efficient way to do that? Our current method is an infinite loop like so:

while(true){ driver.get (URL) driver.quit(); }

We've tried using .refresh() instead, but our software did not register those as unique hits on the server. Is there a better way? .get() each time seems like a bit of overkill.

hollingsworthd commented 7 years ago

I would do:

JBrowserDriver driver = JBrowserDriver(Settings.builder().userDataDirectory(DATA_DIR).build());
while(true){
  driver.get(URL);
  driver.get("about:blank");
  driver.manage().deleteAllCookies();
  org.apache.commons.io.FileUtils.cleanDirectory(DATA_DIR);
}

Caching is disabled by default so getting about:blank, clearing cookies, and clearing local storage should be enough to effectively reset the state.

hollingsworthd commented 7 years ago

Note that underlying tcp connections may be kept alive. JBrowserDriver.reset(..) would probably close them (in addition to clearing cookies and local storage) but there's a memory leak in that API. There's an open issue where someone suggested how to fix it, #204. Pull requests welcome.

ghost commented 7 years ago

OK, but do we still need to call .get() on each iteration no matter what? Is there no faster way? For example, would doing driver.navigate().to(Same URL) be faster? Or is that the same as .get() under the surface?

On Oct 17, 2016 9:19 AM, "D. Hollingsworth" notifications@github.com wrote:

Note that underlying tcp may be kept alive. JBrowserDriver.reset(..) would probably close them (in addition to clearing cookies and local storage) but there's a memory leak in that API. There's an open issue where someone suggested how to fix it. Pull requests welcome.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MachinePublishers/jBrowserDriver/issues/209#issuecomment-254204856, or mute the thread https://github.com/notifications/unsubscribe-auth/AD3fqqjlpFoqBRW9tGyjUn9VZKYJ_bvfks5q03X6gaJpZM4KYLti .

hollingsworthd commented 7 years ago

Get needs to be called and there's no faster alternative. If you want get itself to be faster you can disable javascript although with most websites accurately performance testing them would require JS to be enabled, as the JS would often be making http requests back to the server under test.

ghost commented 7 years ago

Ok. We will try disabling Javascript. To confirm, driver.navigate.to(url) is the same performance as driver.get(url)?

On Oct 17, 2016 12:55 PM, "D. Hollingsworth" notifications@github.com wrote:

Get needs to be called and there's no faster alternative. If you want get itself to be faster you can disable javascript although with most websites accurately performance testing them would require JS to be enabled, as the JS would often be making http requests back to the server under test.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MachinePublishers/jBrowserDriver/issues/209#issuecomment-254266328, or mute the thread https://github.com/notifications/unsubscribe-auth/AD3fqgq0GtVFac-vDbx6ZwN0UOI-HrHWks5q06iDgaJpZM4KYLti .

hollingsworthd commented 7 years ago

Confirmed. Navigate.to is implemented by calling driver.get. Per Selenium API they're by design the same contract.