3

I built a Chrome-extension, and I would like to make an automatic Selenium test, in order to test it.

This is the code I wrote in java:

public static void main(String[] args) throws InterruptedException {

    WebDriver Driver = null;
    System.setProperty("webdriver.chrome.driver","chromedriver.exe");
    Driver = new ChromeDriver();
    ChromeOptions options = new ChromeOptions();
    options.addExtensions(new File("EXTENSTION-TRY_v1.crx"));

    DesiredCapabilities cap = DesiredCapabilities.chrome();
    cap.setCapability(options.CAPABILITY, options);
    Driver = new ChromeDriver(cap);

    //Driver.get("chrome-
      extension://gnenabaciggjinojhciofkkiphbmcinf/home.html");

But everytime I ran it, I get this error:

Requests to the server have been blocked by an extension. Try disabling your extensions. ERR_BLOCKED_BY_CLIENT

AdBlock is disabled. Do you know how can I solve this issue?

Thank you

1 Answers1

0

Here are the arguments I use for starting ChromeDriver:

Map<String, Object> options = new HashMap<String, Object>();
ArrayList<String> args = new ArrayList<String>();
args.add("enable-automation");
args.add("test-type=browser");
args.add("disable-plugins");
args.add("disable-infobars");
options.put("args", args);

capabilities.setCapability(ChromeOptions.CAPABILITY, options);

I also have a different method for loading the extension in this answer.

MivaScott
  • 1,763
  • 1
  • 12
  • 30