I'm trying to run a Selenium test with Java and Edge Dev (based on Chromium). I have downloaded the driver binary (msedgedriver.exe
, 64-bits in my case) from here.
The version of my Edge Dev installed on Windows 10 is 76.0.152.0 (Official build dev 64-bit):
Then, I have the following JUnit 4 test:
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
public class EdgeDevTest {
private WebDriver driver;
@BeforeClass
public static void setupClass() {
System.setProperty("webdriver.edge.driver",
"C:\\Users\\boni\\Downloads\\msedgedriver.exe");
}
@Before
public void setupTest() {
driver = new EdgeDriver();
}
@After
public void teardown() {
if (driver != null) {
driver.quit();
}
}
@Test
public void test() {
driver.get("https://bonigarcia.github.io/selenium-jupiter/");
assertThat(driver.getTitle(),
containsString("JUnit 5 extension for Selenium"));
}
}
... which fails as follows:
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'
System info: host: 'LAPTOP-T9O4060I', ip: '192.168.99.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_111'
Driver info: driver.version: EdgeDriver
remote stacktrace: Backtrace:
Ordinal0 [0x00007FF7894D9442+1741890]
Ordinal0 [0x00007FF78943D692+1103506]
Ordinal0 [0x00007FF7893C828F+623247]
Ordinal0 [0x00007FF78936932A+234282]
Ordinal0 [0x00007FF7893699A3+235939]
Ordinal0 [0x00007FF78936794F+227663]
Ordinal0 [0x00007FF789349BC7+105415]
Ordinal0 [0x00007FF78934B2CE+111310]
GetHandleVerifier [0x00007FF78966D249+1471113]
GetHandleVerifier [0x00007FF78959C525+615781]
GetHandleVerifier [0x00007FF78959C2C1+615169]
Ordinal0 [0x00007FF7894E91CC+1806796]
GetHandleVerifier [0x00007FF78959CC56+617622]
Ordinal0 [0x00007FF78945748E+1209486]
Ordinal0 [0x00007FF78946483C+1263676]
Ordinal0 [0x00007FF7894636BD+1259197]
BaseThreadInitThunk [0x00007FF86D337974+20]
RtlUserThreadStart [0x00007FF86D7FA271+33]
Any idea?
To use WebDriver to automate Microsoft Edge, if you use Selenium, you must use Selenium 4, which has built-in support for Microsoft Edge (Chromium).
I'm happy to see Selenium IDE available in Edge! This is the same great browser automation plugin that you can find in Chrome and Firefox. Beyond being an indispensable testing tool for quickly creating tests, this is great for automating everyday tedious tasks when working with websites.
What is Selenium EdgeDriver? Microsoft offers Microsoft WebDriver to execute the Selenium WebDriver automation tests on the Edge browser. Additionally, the driver allows the selenium tests to communicate with the Edge browser for executing Selenium tests.
Just to close this issue, based on the answer by Jools, I have updated my test (using the latest version of WebDriverManager) and now it is working:
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;
import io.github.bonigarcia.wdm.WebDriverManager;
public class EdgeDevTest {
private WebDriver driver;
@BeforeClass
public static void setupClass() {
WebDriverManager.edgedriver().setup();
}
@Before
public void setupTest() {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary(
"C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe");
EdgeOptions edgeOptions = new EdgeOptions().merge(chromeOptions);
driver = new EdgeDriver(edgeOptions);
}
@After
public void teardown() {
if (driver != null) {
driver.quit();
}
}
@Test
public void test() {
driver.get("https://bonigarcia.github.io/selenium-jupiter/");
assertThat(driver.getTitle(),
containsString("JUnit 5 extension for Selenium"));
}
}
Just got it working. My setup is a little different from yours because I'm using a grid, but it should be fairly similar.
For me, when requesting a driver from the grid I use the chrome capabilities:
m_capability = DesiredCapabilities.chrome();
m_capability.setCapability( "browserName", "chrome" );
So in your case I guess you'll want this instead:
driver = new ChromeDriver();
When launching a node I specify the chrome driver to point to the edge driver (I have it on the PATH, so no need for absolute path)
java -Dwebdriver.chrome.driver=msedgedriver.exe ...
So in your case you'll want this instead:
System.setProperty("webdriver.chrome.driver",
"C:\\Users\\boni\\Downloads\\msedgedriver.exe");
Another thing to remember is to have the location of Edge executable (see below) on your PATH
For Edge Dev you'll want to add:
C:\Program Files (x86)\Microsoft\Edge Dev\Application\
Or if you're using Canary, it's probably:
C:\Users\boni\AppData\Local\Microsoft\Edge SxS\Application\
I am using "chromium edge" Version 80.0.361.5 (Official build) dev (64-bit), I tried the way provided by Jools, but it didn't work for me.
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);
EdgeDriver does not currently work on 'msedgedriver.exe'. There is a PR on Selenium to support that https://github.com/SeleniumHQ/selenium/pull/7164
One way to work around is to use ChromeDriver and rename 'msedgedriver.exe' to 'chromedriver.exe' to trick ChromeDriver into launching MSEdge.
Selenium Using C#. Please find below unit test project using C# for Edge Beta. Hope this helps someone!
You will need Edge Beta Driver and browser exe Link
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
namespace EdgeBetaProject
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
IWebDriver _driver=null;
var driverService = ChromeDriverService.CreateDefaultService(@"Folder Path where driver is present", "msedgedriver.exe");
var driverOptions = new ChromeOptions
{
BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge Beta\Application\msedge.exe"
};
_driver = new ChromeDriver(driverService, driverOptions);
_driver.Navigate().GoToUrl(@"https://www.google.com/");
_driver.Quit();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With