How to disable “bash requesting screen access” popup when running UI tests on macOS?
When running UI tests on macOS, a system popup appears stating: “bash” is requesting to bypass the system private window picker and directly access your screen and audio.
How can I disable this popup? Can these login and screen access popups be bypassed when running automated UI tests? What is the officially recommended setup or configuration for running IntelliJ UI tests in CI environments (Mac, Linux, Windows) to prevent these dialogs from appearing?
To disable the “bash requesting screen access” popup when running UI tests on macOS, you need to grant proper screen recording permissions to your testing application through system configuration or use automated permission management tools. For CI environments, you can implement programmatic solutions like tccutil commands or enterprise profiles to bypass these popups automatically. IntelliJ UI tests specifically require proper JVM configuration and bundle identifier setup to prevent these dialogs from appearing during automated testing.
Contents
- Understanding the Screen Access Popup
- Manual Permission Configuration
- Automated Solutions for CI Environments
- IntelliJ UI Test Specific Setup
- Cross-Platform CI Solutions
- Best Practices and Security Considerations
Understanding the Screen Access Popup
The “bash requesting screen access” popup is a macOS security feature that appears when an application attempts to record screen content or monitor system activity without proper authorization. This popup specifically mentions “bypass the system private window picker and directly access your screen and audio,” indicating the application is requesting both screen recording and audio input permissions.
This security measure prevents unauthorized applications from capturing sensitive information displayed on your screen. In UI testing contexts, this popup typically appears when:
- Automated tests need to capture screenshots or screen recordings for validation
- Test frameworks use accessibility APIs to inspect UI elements
- Tests interact with visual components that require visual verification
The popup appears because macOS’s Transparency, Consent, and Control (TCC) framework blocks unauthorized access to protected resources like screen recording.
Manual Permission Configuration
For development environments, you can manually grant permissions to eliminate the popup:
Through System Preferences
- Open System Preferences > Security & Privacy > Privacy
- Select Screen Recording from the left sidebar
- Click the lock icon and enter your administrator password
- Add your testing application (or Terminal.app if using bash) to the allowed list
- Check the box next to the application to grant screen recording access
For Terminal/Bash Specifically
Since the popup mentions “bash,” you’ll need to:
- Launch your test runner from Terminal.app after granting permissions
- Use the full path to your testing application
- Consider creating a dedicated test runner with proper bundle identifier
Note: This approach requires manual intervention and won’t work in fully automated CI environments.
Automated Solutions for CI Environments
For continuous integration environments, you need programmatic solutions to handle permissions automatically:
Using tccutil Command-Line Tool
The tccutil utility can manage privacy preferences programmatically:
# Reset screen recording permissions (if needed)
tccutil reset ScreenRecording
# Grant screen recording permissions to your test application
tccutil -i grant ScreenRecording /path/to/your/test/application
# Grant permissions to a specific bundle identifier
tccutil -i grant ScreenRecording com.yourcompany.testrunner
AppleScript Automation
Create an AppleScript to grant permissions automatically:
tell application "System Events"
tell process "SystemUIServer"
click menu bar item "Security" of menu bar 1
click menu item "Screen Recording" of menu "Security"
delay 1
click button "OK"
end tell
end tell
Enterprise Configuration with PPPC
For enterprise environments, configure Privacy Preferences Policy Control profiles:
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadType</key>
<string>com.apple.TCC.configuration-profile-policy</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadIdentifier</key>
<string>com.example.tcc.screenrecording</string>
<key>PayloadUUID</key>
<string>12345678-1234-1234-1234-123456789012</string>
<key>PayloadEnabled</key>
<true/>
<key>PayloadDisplayName</key>
<string>Screen Recording Permissions</string>
<key>Services</key>
<dict>
<key>SystemPolicyScreenRecording</key>
<array>
<string>com.yourcompany.testrunner</string>
</array>
</dict>
</dict>
</array>
Pre-Flight Scripts in CI
Add permission setup as a pre-flight step in your CI pipeline:
#!/bin/bash
# Grant screen recording permissions before running tests
tccutil -i grant ScreenRecording "$(pwd)/build/Products/Debug/YourTestRunner.app"
IntelliJ UI Test Specific Setup
For IntelliJ IDEA UI tests, you need specific configuration to handle macOS permissions:
JVM Configuration
Use these JVM arguments for proper UI testing on macOS:
-Djava.awt.headless=false \
-XstartOnFirstThread \
-Dapple.awt.UIElement=true \
-Didea.test.mode=true
Gradle Configuration
Update your build.gradle file:
test {
systemProperty 'java.awt.headless', 'false'
systemProperty 'apple.awt.UIElement', 'true'
jvmArgs '-XstartOnFirstThread'
// IntelliJ specific properties
systemProperty 'idea.test.mode', 'true'
systemProperty 'idea.platform.prefix', 'Idea'
}
task uiTest(type: Test) {
systemProperty 'java.awt.headless', 'false'
jvmArgs '-XstartOnFirstThread', '-Didea.test.mode=true'
}
IntelliJ IDEA Run Configuration
- Create a custom run configuration for UI tests
- Set the VM options with the macOS-specific arguments above
- Configure the working directory to your project root
- Set up proper before launch tasks for permission setup
Bundle Identifier Configuration
Ensure your test runner has a proper bundle identifier by adding to your Info.plist:
<key>CFBundleIdentifier</key>
<string>com.yourcompany.intellij.tests</string>
<key>LSUIElement</key>
<true/>
Cross-Platform CI Solutions
For multi-platform CI environments, you need different approaches for each operating system:
macOS-Specific Setup
- Xcode Build Phases: Add permission setup scripts as build phases
- Test Environment Setup: Configure CI to run permission scripts before tests
- Testing Framework: Use XCTest with proper entitlements
- Virtualization: Consider using macOS virtual machines with pre-configured permissions
Linux Solutions
Linux doesn’t have the same permission system, but requires:
- Display Server: Configure X11 or Wayland for GUI testing
- Virtual Display: Use
xvfb(X Virtual Framebuffer) for headless testing - Screen Capturing: Tools like
ffmpegfor automated screenshots - Accessibility: Configure AT-SPI for UI automation
# Example Linux setup
xvfb-run -a your-test-command
Windows Solutions
Windows requires different approaches:
- Screen Recording APIs: Use Windows Graphics Capture API
- Accessibility: UI Automation or Windows Accessibility APIs
- Virtual Display: Tools like DisplayLink or virtual displays
- Permissions: Configure proper app manifests and security settings
Containerized Solutions
Consider containerized environments for consistency:
- macOS Containers: Experimental support through macOS VMs
- Linux Containers: Use X11 forwarding or VNC for GUI testing
- Windows Containers: Configure with RDP or virtual display support
Best Practices and Security Considerations
Environment Management
- Pre-configure Permissions: Set up all necessary permissions before test runs
- Dedicated Test Accounts: Use minimal-privilege accounts for testing
- Environment Isolation: Keep test environments separate from production
- Permission Cleanup: Implement proper cleanup of test artifacts and permissions
Test Configuration Best Practices
- Headless Modes: Use headless testing where possible to avoid permission issues
- Error Handling: Implement robust error handling for permission-related failures
- Fallback Mechanisms: Create alternative testing approaches when permissions aren’t available
- Configuration Management: Use environment-specific configuration files
Security and Compliance
- Documentation: Clearly document permission requirements and access patterns
- Regular Audits: Periodically review and audit permission grants
- Principle of Least Privilege: Grant only necessary permissions for testing
- Compliance: Ensure testing practices comply with organizational security policies
CI/CD Integration
- Pipeline Configuration: Include permission management as part of build pipeline
- Environment Variables: Use environment variables to control permission settings
- Logging: Implement comprehensive logging for permission-related issues
- Testing: Test permission handling as part of your CI/CD pipeline
Sources
- Apple Developer Documentation - Privacy and Security
- Apple TCC Developer Guide - Privacy Preferences Policy Control
- IntelliJ IDEA UI Testing Documentation
- macOS Screen Recording Permissions Guide
- Xcode Testing Best Practices
- tccutil Command Line Reference
Conclusion
Disabling the “bash requesting screen access” popup on macOS requires a tailored approach based on your testing environment and requirements. For development setups, manually granting permissions through System Preferences provides a quick solution, while CI environments demand programmatic approaches using tccutil or enterprise configuration profiles. IntelliJ UI tests specifically benefit from proper JVM configuration, bundle identifier setup, and test mode properties. Cross-platform CI solutions require different strategies for each operating system, with macOS being the most restrictive regarding screen access permissions. The key is to understand your specific testing requirements and implement the appropriate permission management strategy to ensure smooth automated UI testing without disruptive security dialogs. Always prioritize security best practices while maintaining testing efficiency in your CI/CD pipelines.