Reputation: 109
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
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".
Upvotes: 1
Views: 17336
Reputation: 109
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.
Upvotes: 1
Reputation: 21383
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/");
}
}
Upvotes: 1
Reputation: 109
@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);
Upvotes: 0
Reputation: 193088
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.
Upvotes: 0