Selenium 4.7.2 升级log处理方式
https://github.com/SeleniumHQ/selenium
官方升级说明中提示了改变了日志方式了
v4.7.2
======
* Grid: Support file downloads on the node (#11277)
* Change chromium service names from whitelisted to allowed (#11409)
* Avoid closing CDP connection in browser implementation since that logic now sits in RemoteWebDriver (Fixes #11401)
* Fix bug where failing Selenium Manager method results in wrong error
* Allow changing chromium driver log timestamp formatting
* Allow ignoring chromedriver build checks using service builders
* Add support for appendLog to msedgedriver service
* Fix msedgedriver log level logic
* Allow setting chromedriver log level from system properties
* Fix chromedriver log level logic
* Remove deprecated Firefox capabilities
* Removing a few bits more of the magic that moves JWP to W3C
* Removing deprecated SUPPORTS_ALERTS and SUPPORTS_SQL_DATABASE caps
* Removing deprecated OVERLAPPING_CHECK_DISABLED cap
* Removing deprecated LOGGING_PREFS cap
* Removing deprecated HAS_TOUCHSCREEN cap
* Removing deprecated HAS_NATIVE_EVENTS cap
* Removing deprecated ENABLE_PROFILING_CAPABILITY cap
* Removing deprecated ACCEPT_SSL_CERTS cap
Selenium 4.7.2 ChromeDriverService 源代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | package org.openqa.selenium.chrome; import com.google.auto.service.AutoService; import java.io.File; import java.io.IOException; import java.time.Duration; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.remote.Browser; import org.openqa.selenium.remote.service.DriverService; public class ChromeDriverService extends DriverService { public static final String CHROME_DRIVER_EXE_PROPERTY = "webdriver.chrome.driver" ; public static final String CHROME_DRIVER_READABLE_TIMESTAMP = "webdriver.chrome.readableTimestamp" ; public static final String CHROME_DRIVER_LOG_PROPERTY = "webdriver.chrome.logfile" ; public static final String CHROME_DRIVER_LOG_LEVEL_PROPERTY = "webdriver.chrome.loglevel" ; public static final String CHROME_DRIVER_APPEND_LOG_PROPERTY = "webdriver.chrome.appendLog" ; public static final String CHROME_DRIVER_VERBOSE_LOG_PROPERTY = "webdriver.chrome.verboseLogging" ; public static final String CHROME_DRIVER_SILENT_OUTPUT_PROPERTY = "webdriver.chrome.silentOutput" ; public static final String CHROME_DRIVER_ALLOWED_IPS_PROPERTY = "webdriver.chrome.withAllowedIps" ; /** @deprecated */ @Deprecated public static final String CHROME_DRIVER_WHITELISTED_IPS_PROPERTY = "webdriver.chrome.whitelistedIps" ; public static final String CHROME_DRIVER_DISABLE_BUILD_CHECK = "webdriver.chrome.disableBuildCheck" ; public ChromeDriverService(File executable, int port, List<String> args, Map<String, String> environment) throws IOException { super (executable, port, DEFAULT_TIMEOUT, Collections.unmodifiableList( new ArrayList(args)), Collections.unmodifiableMap( new HashMap(environment))); } public ChromeDriverService(File executable, int port, Duration timeout, List<String> args, Map<String, String> environment) throws IOException { super (executable, port, timeout, Collections.unmodifiableList( new ArrayList(args)), Collections.unmodifiableMap( new HashMap(environment))); } public static ChromeDriverService createDefaultService() { return (ChromeDriverService)( new ChromeDriverService.Builder()).build(); } public static ChromeDriverService createServiceWithConfig(ChromeOptions options) { return (ChromeDriverService)( new ChromeDriverService.Builder()).withLogLevel(options.getLogLevel()).build(); } @AutoService ({org.openqa.selenium.remote.service.DriverService.Builder. class }) public static class Builder extends org.openqa.selenium.remote.service.DriverService.Builder<ChromeDriverService, ChromeDriverService.Builder> { private boolean disableBuildCheck = Boolean.getBoolean( "webdriver.chrome.disableBuildCheck" ); private boolean readableTimestamp = Boolean.getBoolean( "webdriver.chrome.readableTimestamp" ); private boolean appendLog = Boolean.getBoolean( "webdriver.chrome.appendLog" ); private boolean verbose = Boolean.getBoolean( "webdriver.chrome.verboseLogging" ); private boolean silent = Boolean.getBoolean( "webdriver.chrome.silentOutput" ); private String allowedListIps = System.getProperty( "webdriver.chrome.withAllowedIps" , System.getProperty( "webdriver.chrome.whitelistedIps" )); private ChromeDriverLogLevel logLevel = ChromeDriverLogLevel.fromString(System.getProperty( "webdriver.chrome.loglevel" )); public Builder() { } public int score(Capabilities capabilities) { int score = 0 ; if (Browser.CHROME.is(capabilities.getBrowserName())) { ++score; } if (capabilities.getCapability( "goog:chromeOptions" ) != null ) { ++score; } return score; } public ChromeDriverService.Builder withAppendLog( boolean appendLog) { this .appendLog = appendLog; return this ; } public ChromeDriverService.Builder withBuildCheckDisabled( boolean noBuildCheck) { this .disableBuildCheck = noBuildCheck; return this ; } public ChromeDriverService.Builder withVerbose( boolean verbose) { if (verbose) { this .logLevel = ChromeDriverLogLevel.ALL; } this .verbose = false ; return this ; } public ChromeDriverService.Builder withLogLevel(ChromeDriverLogLevel logLevel) { this .verbose = false ; this .silent = false ; this .logLevel = logLevel; return this ; } public ChromeDriverService.Builder withSilent( boolean silent) { if (silent) { this .logLevel = ChromeDriverLogLevel.OFF; } this .silent = false ; return this ; } /** @deprecated */ @Deprecated public ChromeDriverService.Builder withWhitelistedIps(String allowedListIps) { this .allowedListIps = allowedListIps; return this ; } public ChromeDriverService.Builder withReadableTimestamp(Boolean readableTimestamp) { this .readableTimestamp = readableTimestamp; return this ; } protected File findDefaultExecutable() { return ChromeDriverService.findExecutable( "chromedriver" , "webdriver.chrome.driver" , "https://chromedriver.chromium.org/" , "https://chromedriver.chromium.org/downloads" ); } protected List<String> createArgs() { if ( this .getLogFile() == null ) { String logFilePath = System.getProperty( "webdriver.chrome.logfile" ); if (logFilePath != null ) { this .withLogFile( new File(logFilePath)); } } if ( this .verbose) { this .withVerbose( true ); } if ( this .silent) { this .withSilent( true ); } List<String> args = new ArrayList(); args.add(String.format( "--port=%d" , this .getPort())); if ( this .getLogFile() != null ) { args.add(String.format( "--log-path=%s" , this .getLogFile().getAbsolutePath())); if ( this .readableTimestamp) { args.add( "--readable-timestamp" ); } } if ( this .appendLog) { args.add( "--append-log" ); } if ( this .logLevel != null ) { args.add(String.format( "--log-level=%s" , this .logLevel.toString().toUpperCase())); } if ( this .allowedListIps != null ) { args.add(String.format( "--allowed-ips=%s" , this .allowedListIps)); } if ( this .disableBuildCheck) { args.add( "--disable-build-check" ); } return Collections.unmodifiableList(args); } protected ChromeDriverService createDriverService(File exe, int port, Duration timeout, List<String> args, Map<String, String> environment) { try { return new ChromeDriverService(exe, port, timeout, args, environment); } catch (IOException var7) { throw new WebDriverException(var7); } } } } |
Selenium 4.7.1 ChromeDriverService 源代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | package org.openqa.selenium.chrome; import com.google.auto.service.AutoService; import java.io.File; import java.io.IOException; import java.time.Duration; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.remote.Browser; import org.openqa.selenium.remote.service.DriverService; public class ChromeDriverService extends DriverService { public static final String CHROME_DRIVER_EXE_PROPERTY = "webdriver.chrome.driver" ; public static final String CHROME_DRIVER_LOG_PROPERTY = "webdriver.chrome.logfile" ; public static final String CHROME_DRIVER_APPEND_LOG_PROPERTY = "webdriver.chrome.appendLog" ; public static final String CHROME_DRIVER_VERBOSE_LOG_PROPERTY = "webdriver.chrome.verboseLogging" ; public static final String CHROME_DRIVER_SILENT_OUTPUT_PROPERTY = "webdriver.chrome.silentOutput" ; public static final String CHROME_DRIVER_WHITELISTED_IPS_PROPERTY = "webdriver.chrome.whitelistedIps" ; public static final String CHROME_DRIVER_DISABLE_BUILD_CHECK = "webdriver.chrome.disableBuildCheck" ; public ChromeDriverService(File executable, int port, List<String> args, Map<String, String> environment) throws IOException { super (executable, port, DEFAULT_TIMEOUT, args, environment); } public ChromeDriverService(File executable, int port, Duration timeout, List<String> args, Map<String, String> environment) throws IOException { super (executable, port, timeout, args, environment); } public static ChromeDriverService createDefaultService() { return (ChromeDriverService)( new ChromeDriverService.Builder()).build(); } public static ChromeDriverService createServiceWithConfig(ChromeOptions options) { return (ChromeDriverService)( new ChromeDriverService.Builder()).withLogLevel(options.getLogLevel()).build(); } @AutoService ({org.openqa.selenium.remote.service.DriverService.Builder. class }) public static class Builder extends org.openqa.selenium.remote.service.DriverService.Builder<ChromeDriverService, ChromeDriverService.Builder> { private final boolean disableBuildCheck = Boolean.getBoolean( "webdriver.chrome.disableBuildCheck" ); private boolean appendLog = Boolean.getBoolean( "webdriver.chrome.appendLog" ); private boolean verbose = Boolean.getBoolean( "webdriver.chrome.verboseLogging" ); private boolean silent = Boolean.getBoolean( "webdriver.chrome.silentOutput" ); private String whitelistedIps = System.getProperty( "webdriver.chrome.whitelistedIps" ); private ChromeDriverLogLevel logLevel = null ; public Builder() { } public int score(Capabilities capabilities) { int score = 0 ; if (Browser.CHROME.is(capabilities.getBrowserName())) { ++score; } if (capabilities.getCapability( "goog:chromeOptions" ) != null ) { ++score; } return score; } public ChromeDriverService.Builder withAppendLog( boolean appendLog) { this .appendLog = appendLog; return this ; } public ChromeDriverService.Builder withVerbose( boolean verbose) { this .verbose = verbose; return this ; } public ChromeDriverService.Builder withLogLevel(ChromeDriverLogLevel logLevel) { this .logLevel = logLevel; return this ; } public ChromeDriverService.Builder withSilent( boolean silent) { this .silent = silent; return this ; } public ChromeDriverService.Builder withWhitelistedIps(String whitelistedIps) { this .whitelistedIps = whitelistedIps; return this ; } protected File findDefaultExecutable() { return ChromeDriverService.findExecutable( "chromedriver" , "webdriver.chrome.driver" , "https://chromedriver.chromium.org/" , "https://chromedriver.chromium.org/downloads" ); } protected List<String> createArgs() { if ( this .getLogFile() == null ) { String logFilePath = System.getProperty( "webdriver.chrome.logfile" ); if (logFilePath != null ) { this .withLogFile( new File(logFilePath)); } } if ( this .logLevel != null ) { this .withLogLevel( this .logLevel); this .withVerbose( false ); } if ( this .verbose) { this .withLogLevel(ChromeDriverLogLevel.ALL); } List<String> args = new ArrayList(); args.add(String.format( "--port=%d" , this .getPort())); if ( this .getLogFile() != null ) { args.add(String.format( "--log-path=%s" , this .getLogFile().getAbsolutePath())); } if ( this .appendLog) { args.add( "--append-log" ); } if ( this .logLevel != null ) { args.add(String.format( "--log-level=%s" , this .logLevel.toString().toUpperCase())); } if ( this .silent) { args.add( "--silent" ); } if ( this .whitelistedIps != null ) { args.add(String.format( "--whitelisted-ips=%s" , this .whitelistedIps)); } if ( this .disableBuildCheck) { args.add( "--disable-build-check" ); } return Collections.unmodifiableList(args); } protected ChromeDriverService createDriverService(File exe, int port, Duration timeout, List<String> args, Map<String, String> environment) { try { return new ChromeDriverService(exe, port, timeout, args, environment); } catch (IOException var7) { throw new WebDriverException(var7); } } } } |
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 分享4款.NET开源、免费、实用的商城系统
· 解决跨域问题的这6种方案,真香!
· 5. Nginx 负载均衡配置案例(附有详细截图说明++)
· Windows 提权-UAC 绕过
2022-01-04 Database "C:/Users/com/test" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] 90149/90149 (帮助) 解决
2021-01-04 ZIP4j 压缩与解压的实例详解
2020-01-04 Nginx代理webSocket时60s自动断开, 怎么保持长连接
2012-01-04 彻底解决adobe CS5安装过程中安装程序遇到错误(-1)。请重新启动计算机,然后重试。