7

I want to use the following command using selenium/testng inside my code since every-time I execute the code, a new instance of browser is created by webdriver in which security is enabled by default.

chrome.exe --disable-web-security
giri-sh
  • 6,934
  • 2
  • 25
  • 50
SHARAN
  • 182
  • 1
  • 1
  • 13

1 Answers1

15

Try something this, Change the path and slashing accoding to your specifications :-

            WebDriver driver=null;
            System.setProperty("webdriver.chrome.driver","./src//lib//chromedriver");
            DesiredCapabilities capabilities = DesiredCapabilities.chrome();
            ChromeOptions options = new ChromeOptions();
            options.addArguments("test-type");
            options.addArgument("--start-maximized");
            options.addArguments("--disable-web-security");
            options.addArguments("--allow-running-insecure-content");
            capabilities.setCapability("chrome.binary","./src//lib//chromedriver");
            capabilities.setCapability(ChromeOptions.CAPABILITY, options);
            driver = new ChromeDriver(capabilities);
            driver.get("https://www.google.com/");

Below is the link where all available chrome flags are listed :-

http://peter.sh/experiments/chromium-command-line-switches/

Hope it will help you :)

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125