Skip to content

Commit

Permalink
Merge pull request #3595 from thc202/selenium/stats-launch
Browse files Browse the repository at this point in the history
selenium: add simple stats
  • Loading branch information
kingthorin authored Feb 17, 2022
2 parents 4471601 + 19c460d commit de7afd7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions addOns/selenium/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Added
- Statistics, number of browsers launched.

### Fixed
- Quit all browsers when ZAP shuts down ([Issue #6643](https://github.com/zaproxy/zaproxy/issues/6643)).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.zaproxy.zap.extension.script.ScriptType;
import org.zaproxy.zap.extension.script.ScriptWrapper;
import org.zaproxy.zap.extension.selenium.internal.BuiltInSingleWebDriverProvider;
import org.zaproxy.zap.utils.Stats;

/**
* An {@code Extension} that provides {@code WebDriver} implementations for several {@code
Expand Down Expand Up @@ -854,6 +855,7 @@ public static WebDriver getWebDriver(
getWebDriverImpl(
requester, browser, proxyAddress, proxyPort, c -> {}, enableExtensions);
webDrivers.add(wd);
updateStats(browser);
return wd;
}

Expand All @@ -878,9 +880,14 @@ public static WebDriver getWebDriver(
WebDriver wd =
getWebDriverImpl(-1, browser, proxyAddress, proxyPort, consumer, enableExtensions);
webDrivers.add(wd);
updateStats(browser);
return wd;
}

private static void updateStats(Browser browser) {
Stats.incCounter("stats.selenium.launch." + browser.getId());
}

private static void setCommonOptions(
MutableCapabilities capabilities, String proxyAddress, int proxyPort) {
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
Expand Down

0 comments on commit de7afd7

Please sign in to comment.