Chrome is being controlled by automated test software

后端 未结 13 1020
天涯浪人
天涯浪人 2020-12-01 10:49

I am running automated tests in Chrome with Serenity BDD (Selenium).

I had to download a new ChromeDriver, because my tests could not run -> The test would open Chro

相关标签:
13条回答
  • 2020-12-01 11:16

    If anyone is using Rails 5.1+, which changed the testing structure a bit and Capybara is configured in this file now for system tests:

    application_system_test_case.rb
    

    You can add "args" in the options for driven_by like this:

    driven_by :selenium, using: :chrome, screen_size: [1400, 1400], options: { args: ["--disable-infobars"] }
    
    0 讨论(0)
  • 2020-12-01 11:17

    "disable-infobars" flag has been deprecated, but you can avoid this message by adding the following:

    ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.setExperimentalOption("useAutomationExtension", false);
    chromeOptions.setExperimentalOption("excludeSwitches",Collections.singletonList("enable-automation"));    
    WebDriver driver = new ChromeDriver(chromeOptions);
    
    0 讨论(0)
  • 2020-12-01 11:18
    public WebDriver SetupChromeDriver(){
            //Initialize Chrome Driver
            ChromeOptions options = new ChromeOptions();
            Map<String, Object> prefs = new HashMap<String, Object>();
            prefs.put("safebrowsing.enabled", "true"); 
            options.setExperimentalOption("prefs", prefs); 
            options.addArguments("--disable-notifications");
            options.addArguments("--start-maximized");
            options.addArguments("disable-infobars");
            System.setProperty("webdriver.chrome.driver", "E:/Importent Softwares/Chrome Driver/chromedriver_2.37.exe");
            driver = new ChromeDriver(options);
            return driver;
    }
    
    0 讨论(0)
  • 2020-12-01 11:19

    Add this to the options you pass to the driver:

    options.addArguments("disable-infobars");
    
    0 讨论(0)
  • 2020-12-01 11:20
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("useAutomationExtension", false);
    options.setExperimentalOption("excludeSwitches",Collections.singletonList("enable-automation"));    
    WebDriver driver = new ChromeDriver(options);
    

    Use the above codes for latest Chrome drivers.

    0 讨论(0)
  • 2020-12-01 11:22

    It works for me by using addArguments(array("disable-infobars"))

    This is for facebook/php-webdriver

    $options = new ChromeOptions();
    $options->addArguments(array("disable-infobars"));
    $capabilities = DesiredCapabilities::chrome();
    $capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
    $this->driver = RemoteWebDriver::create('http://localhost:4444/wd/hub', $capabilities);
    
    0 讨论(0)
提交回复
热议问题