SOLVED

Chromium Edge automation with selenium (best practice)

Copper Contributor

Hi Guys,

 

since ChromiumEdge is now available as a canary and a dev version I am also all to curious about how selenium will come into play as it is basically a chromium browser. What webdriver will people use? Is it the edge driver or the chrome driver or a completely new one? 

 

Also how far off will be automating ChromiumEdge when it comes to coding best practises?

 

Hopefully this is a good start for a thought.

 

Greets,

40 Replies

@aseema31 for the time being (hopefully not too much longer), yes, sort-of. You want to use the Chrome* classes and explicitly point them to the msedge on your machine. When the language bindings are all updated and stable, then you can rename to use Edge* classes.

 

Here is a code sample in C# for what I mean:

 

                    var anaheimService = ChromeDriverService.CreateDefaultService(@"c:\drivers", "msedgedriver.exe");
                    var anaheimOptions = new ChromeOptions
                    {
                        BinaryLocation = @"C:\Users\johnjan\AppData\Local\Microsoft\Edge SxS\Application\msedge.exe"
                    };
                    //anaheimOptions.AddArgument("--headless");
                    driver = new ChromeDriver(anaheimService, anaheimOptions);

 

best response confirmed by mmiky123 (Copper Contributor)
Solution

@johnjansen actually it do not open with the edge:  

i installed Edge dev Version 77.0.211.3, and Edge Canary Version 77.0.218.4 too. And I use the Version: 77.0.219.0 driver. My test open chrome, not edge. I tried with chromeoption, with System.setProperty, but still. Can you help me what I do wrong? Thanks! 

@Handariel you need to do it the way my code sample does it: point the code to the exact msedgedriver.exe as well as the msedge.exe that is on the machine.

Hi. So it looks like the chromium edge driver is specifically tailored to chromium edge and its functionality, so it is by default searching for a chromium edge installation. From there it is just like the chromedriver with its functionality.

@mmiky123 Yes, that's correct. Each browser must have it's own Driver that specifically runs that version of the browser. So if you want to automate the Old Edge, you'd use MicrosoftWebDriver. If you want to automate the new Edge, you'd use MSEdgeDriver (and for the time being, tell it where to find the EXE to launch msedge.exe instead of chrome.exe).

Team , I am unable to run the selenium tests in Chrome and Edge(Chromium) in parallel mode . Separately , I am able to execute tests in either of the browsers , but in parallel mode ,only one test is getting succeeded.

@BPascal @johnjansen 

Does "using ChromeDriver and setting the "webdriver.chrome.driver" property" still work?

I am using "chromium edge" Version 80.0.361.5 (Official build) dev (64-bit) and selenium 3.14.0, I doesn't work.

 

I started the "selenium server" with option -Dwebdriver.chrome.driver="pathTo\msedgedriver.exe"

I added the folder containing Edge executable "msedge.exe" on the environment PATH

Then I ran the following code, but it failed

System.setProperty("webdriver.chrome.driver", "C:\\SeleniumPlus\\extra\\msedgedriver.exe");
DesiredCapabilities m_capability = DesiredCapabilities.chrome();m_capability.setCapability(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
WebDriver driver = new ChromeDriver(m_capability);

 

I tried another way and it worked for me:

I started the "selenium server" with option -Dwebdriver.edge.driver="pathTo\msedgedriver.exe"

I added the folder containing Edge executable "msedge.exe" on the environment PATH

 

System.setProperty("webdriver.edge.driver", "C:\\SeleniumPlus\\extra\\msedgedriver.exe");
DesiredCapabilities m_capability = DesiredCapabilities.edge();
WebDriver driver = new EdgeDriver(m_capability);

new EdgeDriver(m_capability); is deprecated, we can use the RemoteWebDriver instead as below:

 

driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), m_capability);

Now I'm having a question, I can we set the "experimental options" for "Chromium Edge"? I asked the same question on stackoverflow at https://stackoverflow.com/questions/59299282/how-to-remove-the-infobar-microsoft-edge-is-being-contr...

 

 

 

@leiwang 

 

I'm able to get chromium edge to launch with setting the webdriver.chrome.driver property to that of the edge driver (appropriately downloaded for the version i'm using), however, I receive a timeout, which force closes the browser. The browser immediately reopens and continues on, but the initial instance is killed off. 

 

Other code which has worked for me is: 

			System.setProperty("webdriver.edge.driver", "Path to > msedgedriver.exe");
			// Setup the Edge chromium driver options for this operating system
			final ChromeOptions chromeOptions = new ChromeOptions();
			chromeOptions.setBinary(applicationPath);
			chromeOptions.setExperimentalOption("useAutomationExtension", false);
			chromeOptions.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));

			final EdgeOptions edgeOptions = new EdgeOptions().merge(chromeOptions);

			final WebDriver webDriver = new EdgeDriver(edgeOptions);

@johnjansen 

 

Is there a straight forward way to use and launch the Edge Chromium driver with Selenium? Thank you. 

@nhatekar yes. Really the best way is to update to the Alpha build of Selenium 4 because that's where we updated Selenium to recognize the new Edge browser. 

 

Here is just a quick C# example that works with Selenium 4 (you can get it from nuget or here:

Selenium 4 

 

                // EdgeOptions() requires using OpenQA.Selenium.Edge
                // Construct EdgeOptions with is_legacy = false
                var edgeOptions = new EdgeOptions(false);
                edgeOptions.BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge Dev\Application\msedge.exe";

                var msedgedriverDir = @"c:\drivers";
                var msedgedriverExe = @"msedgedriver.exe";


                // Construct EdgeDriverService with is_legacy = false too
                var service = EdgeDriverService.CreateDefaultService(msedgedriverDir, msedgedriverExe, false);
                service.EnableVerboseLogging = true;

                var driver = new EdgeDriver(service, edgeOptions);
                driver.Url = "http://www.example.com";

 

@johnjansen 

 

Where's the NuGet package for installing the Edge Chromium drivers?

@leiwang

 

it does not work me iam tryed your code  my details slelenium verstions 3.141.59

edge chromium browser version is 81.0.416.34 (Official build) beta (64-bit)

windows 7 os

my code

ChromeOptions co=new ChromeOptions();
System.setProperty("webdriver.edge.driver", "C:\\Users\\pceqa\\Downloads\\edgedriver_win64\\msedgedriver.exe");

co.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Beta\\Application\\msedge.exe");
co.setExperimentalOption("useAutomationExtension", false);
co.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));

final EdgeOptions edgeOptions = new EdgeOptions().merge(co);

final WebDriver webDriver = new EdgeDriver(edgeOptions);

 

exception is :

 

Starting MSEdgeDriver 81.0.416.34 (03120a7eee79e003b101978167af19f238dd1de0) on port 31062
Only local connections are allowed.
Please protect ports used by MSEdgeDriver and related test frameworks to prevent access by malicious code.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created: No matching capabilities found
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
os.version: '6.1', java.version: '1.8.0_73'
Driver info: driver.version: EdgeDriver
remote stacktrace: Backtrace:
Ordinal0 [0x000000013F8F6DC2+3239362]
Ordinal0 [0x000000013F7E8C62+2133090]
Ordinal0 [0x000000013F6927A4+731044]
Ordinal0 [0x000000013F61EABA+256698]
Ordinal0 [0x000000013F61E3BE+254910]
Ordinal0 [0x000000013F61FA01+260609]
Ordinal0 [0x000000013F61CB9F+248735]
Ordinal0 [0x000000013F5FA1A3+106915]
Ordinal0 [0x000000013F5FB50E+111886]
Ordinal0 [0x000000013F804781+2246529]
GetHandleVerifier [0x000000013F9D5454+767796]
GetHandleVerifier [0x000000013F9D5211+767217]
GetHandleVerifier [0x000000013F9EDFF1+869073]
GetHandleVerifier [0x000000013F9D5CB7+769943]
Ordinal0 [0x000000013F7FA314+2204436]
Ordinal0 [0x000000013F80665E+2254430]
Ordinal0 [0x000000013F824711+2377489]
BaseThreadInitThunk [0x000000007716556D+13]
RtlUserThreadStart [0x00000000773C372D+29]

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:141)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:130)
at edge.edgebrowser.main(edgebrowser.java:36)

 

 

@carlbc18 

does not work  please have u look my code and provide some solution

 

ChromeOptions co=new ChromeOptions();
System.setProperty("webdriver.edge.driver", "C:\\Users\\pceqa\\Downloads\\edgedriver_win64\\msedgedriver.exe");
co.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Beta\\Application\\msedge.exe");
co.setExperimentalOption("useAutomationExtension", false);
co.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));

final EdgeOptions edgeOptions = new EdgeOptions().merge(co);

final WebDriver webDriver = new EdgeDriver(edgeOptions);

 

my exception : 

Starting MSEdgeDriver 81.0.416.34 (03120a7eee79e003b101978167af19f238dd1de0) on port 31062
Only local connections are allowed.
Please protect ports used by MSEdgeDriver and related test frameworks to prevent access by malicious code.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created: No matching capabilities found
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
os.version: '6.1', java.version: '1.8.0_73'
Driver info: driver.version: EdgeDriver
remote stacktrace: Backtrace:
Ordinal0 [0x000000013F8F6DC2+3239362]
Ordinal0 [0x000000013F7E8C62+2133090]
Ordinal0 [0x000000013F6927A4+731044]
Ordinal0 [0x000000013F61EABA+256698]
Ordinal0 [0x000000013F61E3BE+254910]
Ordinal0 [0x000000013F61FA01+260609]
Ordinal0 [0x000000013F61CB9F+248735]
Ordinal0 [0x000000013F5FA1A3+106915]
Ordinal0 [0x000000013F5FB50E+111886]
Ordinal0 [0x000000013F804781+2246529]
GetHandleVerifier [0x000000013F9D5454+767796]
GetHandleVerifier [0x000000013F9D5211+767217]
GetHandleVerifier [0x000000013F9EDFF1+869073]
GetHandleVerifier [0x000000013F9D5CB7+769943]
Ordinal0 [0x000000013F7FA314+2204436]
Ordinal0 [0x000000013F80665E+2254430]
Ordinal0 [0x000000013F824711+2377489]
BaseThreadInitThunk [0x000000007716556D+13]
RtlUserThreadStart [0x00000000773C372D+29]

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:141)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:130)
at edge.edgebrowser.main(edgebrowser.java:36)

 

 

 

@PraveenRaj13 

 

This problem is very probably related to the Microsoft Chromium Edge's version,  before version 80, you can treat it like a chrome browser; but from version 80 you have to use EdgeDriver and EdgeOptions to handle it.

 

See my detail explanation at stackoverflow

https://stackoverflow.com/questions/59299282/how-to-remove-the-infobar-microsoft-edge-is-being-contr...

@leiwang 

 

thank u so much.  I'm able to do navigate browser is there any possibility to use selenium 2.53 version or   what are the versions support for selenium for this please give your solution 

@PraveenRaj13 this article should be able to help you. It has information for different versions of Selenium and WebDriver, though 2.53 is too old - it does not have any knowledge of Microsoft Edge, unfortunately.

https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium

-John

@johnjansen 

Thank u john

we are getting struck with disable save password POP up .unable to disable this pop i tryed with below capabilities  but its not working so kindly help us

 

edgeOptions.setExperimentalOption("credentials_enable_service", false);
edgeOptions.setExperimentalOption("profile.password_manager_enabled", false);

 

 

 

 

 

@mmiky123 

Hi buddy 

 

i have migrate IE 11 to edge chromium browser. i had install edge chromum browser now i facing issue on flash player error . than i install flash  player also enable flash on my browser setting also but no luck so kindly give me a solution . i was  tried lost one 3 day 

 

system info 

OS win 7 

browser version 80 x

flash player version 33x

Error popup Message 

"You must have a more recent version of Adobe® Flash® Player installed to view this site.  "

 

please share your valuable solution 

 

Thanks

Praveen raj  

 

 

Hi dude

Any update on this issue

@PraveenRaj13 this should probably be a new thread. The current thread is about Selenium, and I don't want to muddy the conversation. 

 

-John