Is it possible to use Google Chrome instead of chromedriver with selenium? - google-chrome

Is there a way to use standard chrome instance instead of chromedrive.exe with selenium?
The chrome driver that is designed for selenium does not save cookies or browser state when being initialized.
For example, the installed instance of chrome is able to bypass 2-factor auth because it can remember that it is a known device in the remote system. On the other hand, the selenium chrome driver is unable to bypass 2-factor auth because it cannot remember its a known device.
I want to use the installed Google Chrome instead of the chromedriver.exe with selenium web driver. Can this be done?

You have to add, in the ChromeOptions the interested profile path.
Open your Chrome Browser and go to the chrome://version/ page.
And get the profile path.
For example, for me:
So, in Java:
String chromeDriver = "/pathTo/chromedriver";
System.setProperty("webdriver.chrome.driver", chromeDriver);
ChromeOptions options = new ChromeOptions();
String dir= "/Volumes/Macintosh HD/Users/DurdenP/Library/Application Support/Google/Chrome/";
options.addArguments("user-data-dir="+dir);
ChromeDriver driver = new ChromeDriver(options);

Related

Chrome headless executes test over 40 seconds

I have issue with running tests in headless mode with chrome options.
ChromeOptions options = new ChromeOptions(); options.addArguments("--headless"); driver = new ChromeDriver(options);
In UI mode test is executed fast(4seconds), but when I enable headless mode (40 seconds)
Headless mode:
UI mode:
Is there any other way to use chrome headless, whether something is changed in the mean time in driver itself? I have tried with different java, browser version and chrome driver and issue is the same..
Selenium 4.3.0, TestNG 7.4.0

Why doesn't ChromeDriver require Chrome or Chromium?

ChromeDriver is working on my system even though I don't have Chrome or Chromium installed. Based on the name, I thought it was like a "car driver" where you still need a car to get going. Or maybe like a product's API where you still need the product for your API calls to accomplish something.
Edit: Whoops, Chromium is installed after all.
Of course ChromeDriver requires Chrome or Chromium.
As per ChromeDriver - WebDriver for Chrome ChromeDriver is a separate executable that WebDriver uses to control Chrome.
Now, as per Requirements - ChromeDriver the server expects you to have Chrome installed in the default location for each system as follows:
1For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary.
You can also force ChromeDriver to use a custom location by setting a special capability. You can find the documentation in Using a Chrome executable in a non-standard location

Adobe Flash in Selenium, Chrome 54.0.2840.59-1: "This plugin is not supported"

The newest update to Chrome 54.0.2840.59-1 causes selenium to not load Flash plugins. Adobe Flash Player in chrome://plugins/ is disabled, but it's also disabled in the previous version of Chrome.
This only occurs in tests when the Chromedriver is spun up, navigating to a Flash site in a normal Chrome browser shows no issues.
Installing flash player from https://get.adobe.com/flashplayer/ works for me on mac OS, note that you will need to install this on the chrome driver browser (not the chrome browser in your system). To do this, run your selenium test that opens the chrome and from there go to that URL ^ and follow install steps. After you are done, the next time you run the test it should pick up the change and should work.
#sircapsalot: it is possible and we do have automation for our app which is built in flash. It required that we add custom flex handlers which can then be called through javascript.
Linux: To get flash working on chrome 54, I took a working copy of the plugin file from my /usr/google-chrome, then I was able to use pass in a command line argument to chromedriver:
ClassLoader classLoader = getClass().getClassLoader();
File flashPath = new File(classLoader.getResource("libpepflashplayer.so").getFile());
ChromeOptions options = new ChromeOptions();
options.addArguments("--ppapi-flash-path=" + flashPath);
return new ChromeDriver(serviceBuilder.build(), options);
Windows: #user7038292's solution to install flash manually resolved the issue
Chrome 54 doesn't support Adobe Flash Player NPAPI anymore.So you just should install Adobe Flash Player PPAPI (from https://get.adobe.com/flashplayer/ ) on chrome browser in your system.
HashMap<String, Object> chromePrefs = new HashMap<>();
chromePrefs.put("plugins.plugins_enabled", new String[] {
"Chrome PDF Viewer",
"Native Client"
});
chromePrefs.put("plugins.plugins_disabled", new String[] {
"Adobe Flash Player"
});
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromePrefs);
Since Chrome 53, they have blocked flash from loading on their browsers. You are using 54, so it applies.
Secondly, Selenium cannot automate Flash, so i think this question is pointless anyway. If you need to automate flash, you should consider another library.
Installing Flash fixed the issue for me, I used chrome's pepperflash before and encountered the same issue you're describing.

Chrome error "you are using an unsupported command-line flag: --ignore-certificate-errors."

I am using Coded UI for testing my web application on Chrome. I am using the Cross Browser support offered by Coded UI.
I am using the below versions -
Visual Studio: 2013
selenium dotnet bindings: 2.43
When I start the web application in Chrome with BrowserWindow.CurrentBrowser = "Chrome", the chrome browser opens with the popup - "you are using an unsupported command-line flag: --ignore-certificate-errors. ...".
I found some suggestions on web but those seem to be for those who are directly using Selenium.
But, they do not seem to be applicable here as I am using Coded UI.
Can anyone tell me how do I address this problem?
Regards,
kvk1985
Please use below code, it worked me...
IWebDriver driver;
ChromeOptions options = new ChromeOptions();
options.AddArguments("--disable-extensions");
options.AddArgument("test-type");
options.AddArgument("--ignore-certificate-errors");
options.AddArgument("no-sandbox");
driver = new ChromeDriver(options);
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl("https://ahn-qa2.aon.com/home.aspx");
I was experiencing the same issue in Visual Studio 2013 Premium Update 4.
The latest version of chromedriver.exe (2.12) addressed the issue for us.
Download the applicable zip from the 2.12 directory at http://chromedriver.storage.googleapis.com/index.html
Right click on the downloaded zip file.
Select "properties".
Under "General" tab, click on the "Unblock" button.
Now unzip both the files and copy the contents to the following path. Copy over the existing version of chromedriver.exe
"%ProgramFiles%\Common Files\microsoft shared\VSTT\Cross Browser Selenium Components" (for 32 bit machines)
"%ProgramFiles(x86)%\Common Files\microsoft shared\VSTT\Cross Browser Selenium Components" (for 64 bit machines)
Launch Chrome with BrowserWindow.CurrentBrowser = "Chrome" again, the message should be gone.

Can I use Watir webdriver with Chromium?

I have only managed to execute tests with Google Chrome (using the chromedriver).
Can anyone give an example how to start executing tests with Chromium?
Make sure your Chromium binary can be located or set it explicitly.
Selenium::WebDriver::Chrome.path = '/usr/bin/chromium'
driver = Selenium::WebDriver.for :chrome
browser = Watir::Browser.new driver
I think it should be possible, you just have to provide path to Chromium. A few pages you should check:
http://code.google.com/p/selenium/wiki/ChromeDriver
http://watirwebdriver.com/chrome/
Use Selenium with Chromium Browser