Remove security message using Selenium WebDriver with Java - selenium

While running Selenium automated tests on Chrome, I get following type of error message:
You're using an unsupported command line flag: ignore-certificate-errors. Stability and security will suffer
Can someone please suggest how can I remove it using Selenium WebDriver with Java?

Set mode "test-type" to ChromeDriver capabilities
Here's my sample code in Java
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type", "start-maximized",
"no-default-browser-check");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);

If you are using chrome version 35.x, this kind of pop-up will come. Try using chrome version 34.x and then see.
Actually its the problem with chrome builds. Just give it a try.
Thank you,
Shravan Kumar.T

Related

What is the best way to check whether a browser extension has finished installing in Selenium?

A browser extension can be installed for a ChromeDriver object by using the following code:
ChromeOptions options = new ChromeOptions();
options.addExtensions(new File(pathToExtension));
ChromeDriver driver = new ChromeDriver(options);
This works perfectly, however I'd like to check whether installation of this extension is completed. Is there a way to do this in Selenium? I know how to let Selenium wait for a given amount of time, but I wondered if there is a cleaner solution.

Selenium FindElement and Chrome in Headless mode

After starting chromedriver.exe in headless mode following this advice and using just these arguments
options.AddArgument("headless");
options.AddArgument("window-size=1280,960");
The chromedriver opens invisibly. But Selenium's FindElement() command is not finding anything on the headless Chrome page. Instead it throws this exception:
An exception of type 'OpenQA.Selenium.NoSuchElementException' occurred in WebDriver.dll but was not handled in user code
Additional information: no such element: Unable to locate element:
Q1: Has anyone had success running Selenium commands in Chrome's headless mode?
Q2: Have you been able to use FindElement with a chromedriver running in headless mode? If yes, how did you do it?
After reading more, perhaps something along these lines may be necessary? Add this to the Chrome startup options and then maybe connect chromedriver to it?
"remote-debugging-port=9222"
But with that option the IWebDriver and chromedriver does not open.
Background info: to answer, why would you want to do this? The primary reason was for tests run as a part of CI. These are tests that run on a VM and may not support 1080p monitors. If we ran it in headless mode and set the resolution that way we could.
Add below lines of code in your main class:
ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
options.addArguments("--window-size=1920,1080");
options.addArguments("--disable-gpu");
options.addArguments("--disable-extensions"); options.setExperimentalOption("useAutomationExtension", false); options.addArguments("--proxy-server='direct://'");
options.addArguments("--proxy-bypass-list=*");
options.addArguments("--start-maximized");
options.addArguments("--headless");
WebDriver driver = new ChromeDriver(options);

Maximizing Safari window with selenium sometimes fails

I'm using Selenium RemoteWebDriver to run tests written in Java on a remote MacBook. I maximize the browser window using:
driver.manage().window().maximize();
This works 100% of the time for Chrome, Firefox and IE11. But with Safari this seems to fail about 30% of the time. I thought maybe there could be some extra synchronization issues with Safari so I tried:
Thred.sleep(10*1000);
driver.manage().window().maximize();
Thred.sleep(10*1000);
Unfortunately this did not help. I'm getting the error message:
TimeoutException: Timed out awaiting response to command "maximizeWindow"
Does anyone know how to solve this?
Edit: Since it might matter, here's the URL and Capabilities I'm using to create the driver:
DesiredCapabilities caps = DesiredCapabilities.safari();
LoggingPreferences logPrefs;
logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
RemoteWebDriver driver= new RemoteWebDriver(new URL("http://serverIP/wd/hub"), caps)

How to test multiple version of google chrome using chromedriver?

selenium web-driver with java then how to use chrome driver for test their lower version of Google chrome
From the official wiki page:
Overriding the Chrome binary location
You can specify the location of the Chrome binary by passing the "chrome.binary" capability, e.g. with a typical Chromium install on Debian:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.binary", "/usr/lib/chromium-browser/chromium-browser");
WebDriver driver = new ChromeDriver(capabilities);
I suggest you try this approach - tell where the binary of lower version is and start ChromeDriver. Never tried it, but I think it might work
You would use capabilities to point to the right binary file of the browser to be launced.But not all versions of chrome browser is supported by different versions of chromedriver. You will find exceptions stating that version of browser expected is greater or equal to 30.0.
For ex:- Chromium Browser(33.0.1729.0 )works fine with ChromeDriver 2.7 and not the with the older ones.
You can choose from all the chromedriver version available from the link below:-
http://chromedriver.storage.googleapis.com/index.html
Install chrome to custom location, be sure to turn off auto-update. Use following code to use non-default binary.
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/binary");
DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver webDriver = new ChromeDriver(desiredCapabilities);

How to disable Flash in selenium remote webdriver

How do I disable the loading of flash objects when using Selenium Remote WebDriver.
It will be helpful if I get a solution for the normal webdriver also.
Since in most cases the Flash object is loaded by a JavaScript
I have tried disabling the javascript on the webdriver and remote webdriver both, but it does not work.
I tried to to disable the JavaScript by:
WebDriver driver = new FirefoxDriver();
((DesiredCapabilities) driver.getCapabilities()).setJavascriptEnabled(false);
I also tried:
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(false);
WebDriver driver = new FireFoxDriver(caps);
For Remote WebDriver i tried:
final DesiredCapabilities firefoxCapability = DesiredCapabilities.firefox();
firefoxCapability.setJavascriptEnabled(false);
new RemoteWebDriver(new URL("http://" + windowsIP + ":4444/wd/hub"), firefoxCapability);
After execution of the above statement the remote server displays
Executing: [new session: <platform=ANY, javascriptEnabled=false, browserName=firefox, version=>] at URL:/session>
but still all the Javascript is executing on the pages the driver loads and the Flash is also loading.
Please help me :
1. how can stop the flash from loading.
2. need it on remote driver as I need to test the pages on IE, Firefox, Chrome. Hence loading the forefox profile will not work
Thank you for the help.
I used this code on Linux mint and it works:
FirefoxProfile profile= new FirefoxProfile();
profile.setPreference("plugin.state.flash", 0);
FirefoxDriver driver = new FirefoxDriver(profile);
though it's already answered question but on different forum... so i will consolidate for you...
I'm not sure if flash objects are loaded by javascript....but if disabling javascript is problem then...
Never disable Javascript for Firefox driver, in case if you want to use it being disabled try with HTMLUNITDRIVER which specially meant for non-javascript pages.
Reason being important parts of firefox driver is implemented in javascript and disabling would have serious concerns.
HtmlUnitDriver on the other hand is fastest and best way for automation tests (splly for pages with no JS)
please check this group discussion
https://groups.google.com/forum/?fromgroups=#!topic/webdriver/daLOzCiU_h4%5B1-25%5D
I had the same problem and needed it to be solved for Chrome. This is how I got it to work:
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-bundled-ppapi-flash");
WebDriver webDriver = new org.openqa.selenium.chrome.ChromeDriver(options);