How to disable “always open these types of links i

2019-08-30 03:07发布

问题:

While executing my Protractor tests in Chrome I'm getting an alert similar to below:

I want to accept it to be able to continue with my tests execution.

First I've tried with browser.switchTo().alert().accept() but it didn't work.

Then I google'd a bit and found the following solution:

chromeOptions: { 
      prefs: { 
        protocol_handler: { 
          excluded_schemes: { 
            "app": true 
          } 
        } 
      },

but it didn't work either.

I need to be able to accept that in order to execute remaining test steps.

回答1:

Try to add --disable-infobars to the config file.

  capabilities: {
    browserName: 'chrome',
    chromeOptions: {
      args: ['--disable-infobars']
    }
  }