我使用 Chrome 进行了自动化测试,它在 Chrome 62 上运行。现在使用 Chrome 版本 63,我的测试不起作用,因为 Flash 未激活。 chromedriver的版本是2.53。
如何在 Chrome 63 上始终启用 Flash?多谢。 这是我的代码:
ChromeOptions options = new ChromeOptions();
Map<String, Object> prefs = Collections.singletonMap("profile.content_settings.exceptions.plugins.*,.per_resource.adobe-flash-player",1);
options.setExperimentalOption("prefs", prefs);
WebDriver driver = new ChromeDriver(options);
最佳答案
要在 Chrome 63.x
上启用 flash,您可以使用以下代码块:
System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_settings.state.flash",1); # 1->allow
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
WebDriver driver = new ChromeDriver(options);
关于java - Selenium 无法在 chrome 63 java 上启用 flash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48205480/