How to disable Flash in selenium remote webdriver

家住魔仙堡 提交于 2019-11-29 13:48:44
Tasawer Khan

I used this code on Linux mint and it works:

FirefoxProfile profile= new FirefoxProfile();
profile.setPreference("plugin.state.flash", 0);
FirefoxDriver driver = new FirefoxDriver(profile);

though it's already answered question but on different forum... so i will consolidate for you...

I'm not sure if flash objects are loaded by javascript....but if disabling javascript is problem then...

Never disable Javascript for Firefox driver, in case if you want to use it being disabled try with HTMLUNITDRIVER which specially meant for non-javascript pages.

Reason being important parts of firefox driver is implemented in javascript and disabling would have serious concerns.

HtmlUnitDriver on the other hand is fastest and best way for automation tests (splly for pages with no JS)

please check this group discussion https://groups.google.com/forum/?fromgroups=#!topic/webdriver/daLOzCiU_h4%5B1-25%5D

I had the same problem and needed it to be solved for Chrome. This is how I got it to work:

    ChromeOptions options = new ChromeOptions();
    options.addArguments("--disable-bundled-ppapi-flash");
    WebDriver webDriver = new org.openqa.selenium.chrome.ChromeDriver(options);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!