欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

UI Automation - Chrome Driver Cannot Load Flash Plugin

程序员文章站 2022-07-13 21:28:36
...
Since Chrome driver won't setup flash plugin by default, then we can add it in coding when initial drvier.

Here is the simple demo:
System.setProperty("webdriver.chrome.driver", "C:/chromedriver.exe");
ChromeOptions options = new ChromeOptions();

//set "--ppapi-flash-path" as pepflashplayer.dll loaction. can check in Chrome browser with "chrome://flash/"
options.addArguments("--ppapi-flash-path=" + installPath);
// add follwing param if always popup outdate message.
options.addArguments("--allow-outdated-plugins=true");

WebDriver driver = new ChromeDriver(options);
// open the home page of Baidu
driver.get("http://www.baidu.com/");

If necessary, here is the way to set all user configurations of Chrome browser for Chrome webdriver, such as tags and plugins.
options.addArguments("user-data-dir=" + System.getProperty("user.home").replace("\\", "/") + "/AppData/Local/Google/Chrome/User Data");