UI Automation - Chrome Driver Cannot Load Flash Plugin

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");

猜你喜欢

转载自pengyao0305.iteye.com/blog/2381514