We are using selenium to run test against "Chromium based Edge".
"The Chromium Edge" is downloaded from https://www.microsoftedgeinsider.com/en-us/download and the version is 80.0.334.2 (Official build) dev (64-bit).
We got the matched driver msedgedriver.exe from https://msedgewebdriverstorage.z22.web.core.windows.net/
We add the "C:\Program Files (x86)\Microsoft\Edge Dev\Application" to the environment "PATH" so that the executable "msedge.exe" will be found during the test.
After starting the selenium server with option -Dwebdriver.edge.driver="pathTo\msedgedriver.exe", we can get the test run in the "Chromium Edge" as below:
But there is a infobar "Microsoft Edge is being controlled by automated test software", just like we run test with chrome browser. With chrome, we can remove that infobar by setting the following ExperimentalOption to ChromeOptions
useAutomationExtension=false
excludeSwitches=[enable-automation]
prefs={credentials_enable_service=false, profile={password_manager_enabled=false}}
I tried to set the same options and I got a browser launched without the infobar, but it is a chrome browser NOT the "Chromium Edge".
You could refer to the following code (C# code) to set the chrome options and remove the infobar.
var edgechromiumService = ChromeDriverService.CreateDefaultService(#"E:\edgedriver_win64", "msedgedriver.exe");
// user need to pass the driver path here....
ChromeOptions edgechromeOptions = new ChromeOptions
{
BinaryLocation = #"C:\Program Files (x86)\Microsoft\Edge Dev\Application\msedge.exe",
};
edgechromeOptions.AddAdditionalCapability("useAutomationExtension", false);
edgechromeOptions.AddExcludedArgument("enable-automation");
using (IWebDriver driver = new ChromeDriver(edgechromiumService, edgechromeOptions))
{
driver.Navigate().GoToUrl("https://www.bing.com/");
Console.WriteLine(driver.Title.ToString());
//driver.Close();
Console.ReadKey();
}
The result like this:
For Java applications, please try to use the following code:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeOptions;
import java.util.*;
public class Edgeauto {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "your\\path\\to\\edge\\webdriver\\msedgedriver.exe");
ChromeOptionschromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe");
chromeOptions.setExperimentalOption("useAutomationExtension", false);
chromeOptions.setExperimentalOption("excludeSwitches",Collections.singletonList("enable-automation"));
EdgeOptions edgeOptions = new EdgeOptions().merge(chromeOptions);
WebDriver driver = new ChromeDriver(edgeOptions);
driver.get("https://www.google.com/");
}
}
I think that I can explain the all the confusions (perhaps for myself 😊). In the following link Microsoft Chromium Edge
We can find something as below:
If you were previously automating or testing Microsoft Edge (Chromium) by using ChromeDriver and ChromeOptions, your WebDriver code will not run successfully against Microsoft Edge 80 or later. This is a breaking change and Microsoft Edge (Chromium) no longer accepts these commands. You must change your tests to use EdgeOptions and Microsoft Edge Driver.
So we can handle the Chromium-Edge (version is smaller than 80) completely as a chrome browser.
System.setProperty("webdriver.chrome.driver", "C:\\SeleniumPlus\\extra\\msedgedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe");
chromeOptions.setExperimentalOption("useAutomationExtension", false);
chromeOptions.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
ChromeDriver driver = new ChromeDriver(chromeOptions);
driver.get("http://www.google.com");
driver.close();
For the Chromium-Edge (version 80 or later), we should treat it as an Edge browser, the code is as below:
The problem is that EdgeOptions does NOT provide enough APIs (setBinary, setExperimentalOption) as ChromeOptions ☹.
I checked the selenium’s source code at github and I found that the EdgeOptions has already supported those methods as ChromeOptions. So I downloaded the latest official build whose version is 3.141.59, and it was released this on Dec 20, 2018 and I found out that it doesn’t contain the latest source code ☹.
So I got the alpha release 4.0.0-alpha-4 and it does contain the latest source code.
System.setProperty("webdriver.edge.driver", "C:\\SeleniumPlus\\extra\\msedgedriver.exe");
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe");
edgeOptions.setExperimentalOption("useAutomationExtension", false);
edgeOptions.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
EdgeDriver driver = new EdgeDriver(edgeOptions);
driver.get("http://www.google.com");
driver.close();
Finally I want to thank my comrade comrade Carl, he helped me find the trick.
You saw it right.
As per the article Microsoft’s Edge Chromium browser will launch on January 15th with a new logo Microsoft is planning to release its Edge Chromium browser on January 15th 2020 with availability for Windows 10, Windows 7, Windows 8, and macOS. This came just after Microsoft released the beta version of Edge.
Now, this Beta also means that Microsoft is edging closer to the release stage for its Chromium browser. Microsoft first released its Canary and Developer builds of Edge back in April, and the company has spent the past four months working alongside Google to improve Chromium for Windows. That work also involved Microsoft getting used to the cadence of delivering a Chromium browser.
Hence adding the ExperimentalOption you see the Microsoft’s Edge Chromium browser almost like a Chromium / Chrome browser.
#Zhi Lv - MSFT
What is the browser you are launching? Chrome or Chromium-Edge? I am using selenium java code, if I run the similar java code as below, it will fail with error
The path to the driver executable must be set by the webdriver.chrome.driver system property;
System.setProperty("webdriver.edge.driver", "C:\\SeleniumPlus\\extra\\msedgedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe");
chromeOptions.setExperimentalOption("useAutomationExtension", false);
chromeOptions.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("http://www.google.com");
If I create an edge capabilities and merge the ChromeOption into it, I can see that "Chromium-Edge" gets started without the "infobar", but it just gets stuck there and fails with an error
unknown error: unrecognized Chrome version: Edg/80.0.361.5
System.setProperty("webdriver.edge.driver", "C:\\SeleniumPlus\\extra\\msedgedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe");
chromeOptions.setExperimentalOption("useAutomationExtension", false);
chromeOptions.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
DesiredCapabilities m_capability = DesiredCapabilities.edge();
m_capability.merge(chromeOptions);
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), m_capability);
driver.get("http://www.google.com");
From the "selenium server" console, I can see, the "browserName" is "chrome", I guess that is the reason why chrome's options is working to get rid of the "infobar"
15:37:55.502 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [
],
"binary": "C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe",
"excludeSwitches": [
"enable-automation"
],
"extensions": [
],
"useAutomationExtension": false
},
"platform": "WINDOWS",
"version": ""
}
If I set the "browserName" to "MicrosoftEdge" after merging the chrome's options as below, it can get the "Chromium-Edge" started, but the chrome's options do not work any more, which means the "infobar" is still there.
m_capability.merge(chromeOptions);
m_capability.setCapability(CapabilityType.BROWSER_NAME, BrowserType.EDGE);
I am trying to handle multiple popup blocker in www.naukri.com; For this I have created a custom profile in firefox naming "AutoProfile". But I am having an issue with loading this custom profile in firefox driver;
System.setProperty("webdriver.gecko.driver", "F:\\abc\\geckodriver-v0.18.0-win64\\geckodriver.exe");
ProfilesIni profile2=new ProfilesIni();
FirefoxProfile profile3=profile2.getProfile("AutoProfile");
profile3.setPreference("browser.popups.showPopupBlocker", false);
driver =new FirefoxDriver(profile3);
driver.get("www.naukri.com");
But I am getting an error in driver=new FirefoxDriver(profile3); It says:
The constructor FirefoxDriver(FirefoxProfile) is undefined.
Some times I get a message as constructor is deprecated.
What are the version of Selenium and the Geckodriver that are you using?
From https://raw.githubusercontent.com/SeleniumHQ/selenium/master/rb/CHANGES
3.4.1 (2017-06-13)
==================
Firefox:
* Added new Firefox::Options class that should be used to customize browser
behavior (command line arguments, profile, preferences, Firefox binary, etc.).
The instance of options class can be passed to driver initialization using
:options key. Old way of passing these customization directly to driver
initialization is deprecated.
In order to set the profile, you should do something like this:
System.setProperty("webdriver.gecko.driver", "F:\\abc\\geckodriver-v0.18.0-win64\\geckodriver.exe");
ProfilesIni profile2 = new ProfilesIni();
FirefoxProfile profile3 = profile2.getProfile("AutoProfile");
profile3.setPreference("browser.popups.showPopupBlocker", false);
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setProfile(profile3);
WebDriver driver = new FirefoxDriver(firefoxOptions);
driver.get("www.naukri.com");
The issue is due to older selenium version coexisted. mvn clean install resolved the issue.
Update gecko driver and library
Hope your problem will be solved
Recently we upgraded our Selenium C# binding , v3.4 and we are start using the Gecko Driver which is for FF support, so we are using v 0.16.1,
We notice that after click that open new window (FF) we got WebDriverException handlers time out, pops from : driver.WindowHandles (Selenium command),
We are wondering if it is common issue or if you know how to workaround that issue?
Init Driver Code:
public void Setup()
{
var driverService = FirefoxDriverService.CreateDefaultService();
driverService.FirefoxBinaryPath = #"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
driverService.HideCommandPromptWindow = true;
driverService.SuppressInitialDiagnosticInformation = true;
m_driver = new FirefoxDriver(driverService, new FirefoxOptions(), TimeSpan.FromSeconds(60));
}
As per the documentation here to work with geckodriver v0.16.0 you need to bump up your Selenium version to 3.4.0. So it essentially means to work with geckodriver v0.16.1 Selenium 3.4.0 is mandatory.
Note that geckodriver v0.16.0 is only compatible with Selenium 3.4 and greater.
Could someone please help me with the following issue.
While I'm trying to initialize a browser I get the 'os error' exception.
var option = new FirefoxOptions();
option.IsMarionette = true;
var driver = new FirefoxDriver(option);
var b = new Browser(driver); // Throws an exception with a message - 'os error'
The screenshot of the exception
Plese note, the path to wires.exe is added to the system PATH. Selenium, wires, firefox are of the latest versions. I have tried running using firefox-stable and firefox-developer editions.
Thanks.
So I ran into the 'os error' issue when I was trying to get Marionette working. The source of the issue in my case was I was trying to use some NuGet package called 'Mozilla Firefox Webdriver 0.6.0.1' which I believe had a very old version of the (now called) geckodriver.exe.
I downloaded the latest version of the driver from here https://github.com/mozilla/geckodriver/releases
renamed to wires.exe and put in my working directory
then I had to initiate the driver using the following code.
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
service.FirefoxBinaryPath = #"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
Driver = new FirefoxDriver(service);
The way you initated the driver was giving me an entity not found exception.
Hope this helps
Maybe DesiredCapabilities would work.
DesiredCapabilities capabilities = DesiredCapabilities.Firefox();
capabilities.SetCapability("marionette", true);
var driver = new FirefoxDriver(capabilities);
When I create the Augmenter (see below) with 2.25 release of Selenium, it used to work fine. With 2.26 and 2.27 I'm getting the following error. Could you please suggest what extra is needed with a 2.26+ release to get things working again?
I get the following error:
java.lang.IllegalAccessException-->Class org.openqa.selenium.remote.Augmenter$CompoundHandler can not access a member of class org.openqa.selenium.firefox.FirefoxDriver with modifiers "protected"Exception caught starting Firefox webdriver
The relevant code:
WebDriver driver = new FirefoxDriver();
WebDriver augmentedDriver = new Augmenter().augment(driver);
Since newer release of selenium Agumenter only works for the RemoteWebDriver.
It was never really supported, but now is also doesn't work
Which feature you need the Agumenter for?
I.e. to take a screenshot you can make make a direct cast of the FriefoxDriver:
((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
To initialize a mixed hub/local driver:
if (useHub) {
...
webDriver = new RemoteWebDriver(hubURL, desiredCapabilities);
webDriver = new Augmenter().augment(webDriver);
} else {
switch(webDriverType) {
case Type.FIREFOX:
webDriver = new FirefoxDriver();
}
}
then use webDriver as normal