Blocking Advertisement on Firefox in Selenium

Home / Uncategorized / Blocking Advertisement on Firefox in Selenium

Question:
I want to extract colors from the webpage so I am using selenium to capture screenshot of webpage but due to advertisement coming on webpage the color pallete has unwanted colors and I have created a custom profile for firefox which uses adblock, adblock gets started on webpage load but ads still appear. This is the piece of code I am using to block ads :FirefoxProfile firefoxProfile = new FirefoxProfile();
File addonpath = new File("/Users/shubham.ga/Downloads/adblock_for_firefox-2.6.0-an+fx.xpi");
firefoxProfile.addExtension(addonpath);
System.setProperty("webdriver.gecko.driver", "/Applications/Firefox.app");
driver = new FirefoxDriver(firefoxProfile);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get(url);


Answer:

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *