New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make clipboard work even in headless mode #1816
Comments
I think it will help, it will accept all permissions DesiredCapabilities caps = new DesiredCapabilities();
// INIT CHROME OPTIONS
ChromeOptions options = new ChromeOptions();
Map<String, Object> prefs = new HashMap<String, Object>();
Map<String, Object> profile = new HashMap<String, Object>();
Map<String, Object> contentSettings = new HashMap<String, Object>();
// SET CHROME OPTIONS
// 0 - Default, 1 - Allow, 2 - Block
contentSettings.put("notifications", 1);
profile.put("managed_default_content_settings", contentSettings);
prefs.put("profile", profile);
options.setExperimentalOption("prefs", prefs);
// SET CAPABILITY
caps.setCapability(ChromeOptions.CAPABILITY, options); |
@kachurinaa I haven't found any working solution for Firefox. :( |
Experiment failed: at least it doesn't work in Firefox. And I didn't find proper Firefox preferences to enable clipboard access.
Try to experiment with that
or this
like this
|
@kachurinaa The permission is not the only problem. Firefox also says that |
@asolntsev |
Found another potential solution: https://www.appsloveworld.com/bestanswer/selenium/138/how-to-fetch-copied-content-from-a-clipboard-selenium-headless-mode |
The problem
Clipboard in Selenide work only in headful mode.
We can make it work in headless mode as well by using JavaScript instead of
java.awt.Toolkit
.To set clipboard content:
To get clipboard content:
NB! Method
getData()
asks for permission. Need to find the webdriver option to suppress this dialog.The text was updated successfully, but these errors were encountered: