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
I have come across many articles which talk of carrying out security testing with selenium however I found it very cumbersome to set up such tests. This is what this tutorial is going to make easy for you.
For the Chrome browser, one can handle the SSL certificates using ChromeOptions class provided by Selenium WebDriver. It is a class that we can use to set properties for the Chrome browser.
Launch a browser and enter “about:config” in URL address bar Double click on “javascript.enabled” available entry to set boolean value as false Note: You can use this website for confirming if your JavaScript is enabled or disabled. Now, we get down to automation testing with Selenium.
Only one thing left, disabling the security checks entirely! To do this you can start another instance of Chrome from your terminal using the --disable-web-security and --ignore-certificate-errors flags.
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With