Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #53 +/- ##
=========================================
Coverage 88.86% 88.86%
Complexity 197 197
=========================================
Files 1 1
Lines 494 494
=========================================
Hits 439 439
Misses 55 55
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Tested Chromedriver 131.0.6778.139 and the issue is still there. Even though https://issues.chromium.org/issues/379125944 reported (if I'm reading that page correctly), that issue was fixed in the 131.0.6778.70. 😞 |
|
I'm using other arguments in the same way you did it (e.g. Could you maybe run it and then either inspect selenium settings in |
Are you using Chrome for Testing or a stable Chrome/Chromium release ? |
I'm using Brave Browser (which is Chromium-based). I guess specifying |
|
This is some sort of security/sandboxing , are we sure we want to disable it? I'd rather document it. MacOS itself should handle cleanup, plus how many people or running Chromedriver on MacOS for CI. |
|
Off-topic warning I have mixed feelings about the default capabilities (including the current one). Cons:
Pros:
In general, I feel like we should have some sort of mechanism (or a sub-project / sub-driver?) to handle capabilities better. For example, it would be nice for our users to just pass a "enable_headless" config which we translate to the right set of capabilities for the specified browser. I haven't spent too much time thinking about this, so it would be really nice if someone else took over or thinks it over. |
@uuf6429 , I've found out why driver defaults weren't used. I'm passing this to allow chromedriver to operate on non-Chrome (Chromium-based) Web Browser: 'goog:chromeOptions' => array(
'binary' => '/Applications/Brave Browser.app/Contents/MacOS/Brave Browser'
),and that completely replaced driver-provided defaults: 'goog:chromeOptions' => [
// disable "Chrome is being controlled.." notification bar
'excludeSwitches' => ['enable-automation'],
'args' => array(
// disable browser folder cloning on Mac, when tests are executed
'disable-features=MacAppCodeSignClone',
),
],. The mix-and-match approach and on/off switch, as @oleg-andreyev proposed, for default desired capabilities is an interesting thing to discuss.
@oleg-andreyev , we're discussing this a bit in the #51 . Probably we can have
@oleg-andreyev , I have no idea what this functionality is (probably Chromium source code at https://source.chromium.org/search?q=MacAppCodeSignClone&sq=&ss=chromium can reveal it), but it surely eats a lot of disk space pretty quickly and since on macOS you don't reboot quite often to auto-clear temp folder (as you do on Windows) you can run out of disk space soon enough. Before creating a PR I prefer to execute the whole Selenium-based test suite locally to see if it passes and only then let GitHub Actions run it. This would save me time waiting for GitHub Actions to crash after some time when I can see the same crash locally and already start to fix things. |
The comments in https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/mac/code_sign_clone_manager.h?q=MacAppCodeSignClone&ss=chromium explain a lot why this was done. If I've understood correctly, then it was done for updating to new version purposes and there is a background process to delete the cloned folder. My guess is that this background process doesn't work or is stopped as long as Selenium-started browser exists as part of I have no idea really why the clones are not deleted, when they should. More links:
|
|
I've created #54 for discussing general problems with desired capability handling. |
|
Found why the clones aren't deleted. The clone is deleted by a cleanup helper process, which the browser launches on normal shutdown (code_sign_clone_manager.mm). But ChromeDriver doesn't shut the browser down normally: when it uses its own temporary profile (the default), it just sends // If we're using a temporary user data directory, we're going to delete the temporary
// directory anyway, so just send SIGKILL immediately.
bool quit_gracefully = quit_gracefully_ || !user_data_dir_.IsValid();So every session leaves a clone in The Chrome for Testing doesn't clone at all (cloning is disabled with So I think the original proposal ( |
|
Merge plan:
P.S. |
b00afd5 to
ffabb66
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ffabb66 to
1dbfc29
Compare
|
I've updated the PR description with the findings from the comments above: why the clones aren't deleted, which browsers are affected and why updating ChromeDriver, |
When executing tests in Google Chrome (or any Chromium-based Web Browser) on Mac you'll notice your temp folder starts to grow faster than lightning strikes.
This happens because upon launching, a Web Browser copies itself (the whole ~300MB app folder) into a temp folder. Normally a cleanup helper deletes that copy when the browser exits, but ChromeDriver kills the browser with
SIGKILL, so the helper never runs (details in #53 (comment)). macOS clears that folder only on reboot.Since numerous sessions are started/stopped during a test suite run, you'll get numerous ~300MB folders residing under a temp folder.
This affects regular Chrome, Edge, Brave, etc. on macOS. Only Chrome for Testing doesn't clone itself.
Solution: specify
--disable-features=MacAppCodeSignClonein the default Chrome arguments. Cloning only matters when the browser is updated while running, which tests don't need. On other OSes the flag does nothing.Why not other options:
goog:chromeOptions.quitGracefully: true: the cleanup helper would run, but every session stop gets slower and a clone is still made on each start;