1

I am having a difficult time with the webdriver for Edge. I know that the driver is installed via the command:

DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0

But what is the next step after this? Here is my code in Java so far:

System.setProperty("webdriver.edge.driver", "[I don't know the path of the install]");
@SuppressWarnings("deprecation")
WebDriver driverEdge = new EdgeDriver(options);
driverEdge.get("https://www.google.com/");
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • The next step would be to find where it's installed... But in general, if you can include the driver executables in your repository, then you'd *always* know where you could find the driver. Are you running your code locally or in a pipeline of some sort? – natn2323 Dec 20 '19 at 19:17

3 Answers3

0
 String windir = System.getenv("windir");
 String edgeDriverPath = windir + "\\SysWOW64\\MicrosoftWebDriver.exe";  
 System.setProperty("webdriver.edge.driver", edgeDriverPath); 
 driver = new EdgeDriver();

This assumes 64-bit and I haven't actually tested it, so please let me know if it works. For 32-bit I believe the directory will by "System32" instead of "SysWOW64".

pcalkins
  • 1,188
  • 13
  • 20
  • Okay- I think I figured out what I was doing wrong. I guess since Windows 10 1903, the Edge Web Driver doesn't have to have a SystemsetProperty. So this is what I have now and am able to run without issues – Joshua Jaynes Dec 20 '19 at 20:46
  • WebDriver driverEdge = new EdgeDriver(); driverEdge.get("https://google.com"); – Joshua Jaynes Dec 20 '19 at 20:48
  • ohhh, I did not know that... System.setProperty will be for Java runtime, but are you saying that the line is not necessary? – pcalkins Dec 20 '19 at 20:51
  • Correct. I only had to use System.setProperty for Chrome, Firefox, and IE11. – Joshua Jaynes Jan 07 '20 at 06:02
  • thanks for letting me know... don't have a Win10 machine to test from at the moment. – pcalkins Jan 07 '20 at 19:02
0

You could find the Microsoft Edge WebDriver from the following folders:

C:\\Windows\\WinSxS\\amd64_microsoft-webdriver-server-components_31bf3856ad364e35_10.0.18362.1_none_c52dd23839475f5b\\MicrosoftWebDriver.exe

C:\\Windows\\System32\\MicrosoftWebDriver.exe

C:\\Windows\\SysWOW64\\MicrosoftWebDriver.exe

C:\\Windows\\WinSxS\\wow64_microsoft-webdriver-server-components_31bf3856ad364e35_10.0.18362.1_none_cf827c8a6da82156\\MicrosoftWebDriver.exe

Then, refer to the following code to use Microsoft Edge WebDriver with Java:

package seleniumtest; 

import org.openqa.selenium.By;
import org.openqa.selenium.Keys; 
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class testsample {

    public static void main(String[] args) { 

         //String windir = System.getenv("windir");
         //String edgeDriverPath = windir + "\\SysWOW64\\MicrosoftWebDriver.exe";  

         //String edgeDriverPath = "C:\\Windows\\WinSxS\\amd64_microsoft-webdriver-server-components_31bf3856ad364e35_10.0.18362.1_none_c52dd23839475f5b\\MicrosoftWebDriver.exe";
         //String edgeDriverPath = "C:\\Windows\\System32\\MicrosoftWebDriver.exe";
         //String edgeDriverPath = "C:\\Windows\\SysWOW64\\MicrosoftWebDriver.exe";

         String edgeDriverPath = "C:\\Windows\\WinSxS\\wow64_microsoft-webdriver-server-components_31bf3856ad364e35_10.0.18362.1_none_cf827c8a6da82156\\MicrosoftWebDriver.exe";

         System.setProperty("webdriver.edge.driver", edgeDriverPath); 
         WebDriver driver = new EdgeDriver();

         //replace the URL of the web page here..
         driver.get("https://www.bing.com");
         //wait page load success.
         WebDriverWait wait = new WebDriverWait(driver, 5);
         wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("sb_form_q")));

         //find the element from the web page.
         WebElement element = driver.findElement(By.id("sb_form_q"));
         //enter value and search
         element.sendKeys("web driver");
         element.sendKeys(Keys.ENTER);  
    }    
}
Zhi Lv
  • 18,845
  • 1
  • 19
  • 30
0

New in EdgeHTML 18

EdgeHTML 18 includes the following new and updated features shipped in the current release of the Microsoft Edge platform, as of the Windows 10 October 2018 Update (10/2018, Build 17763). For changes in specific Windows Insider Preview builds, see the Microsoft Edge Changelog and What's New in EdgeHTML.


As per the Microsoft blog Enhancing automated testing in Microsoft Edge with new WebDriver capabilities, W3C protocol support, and automatic updates:

WebDriver needed to match the version of Microsoft Edge you’re testing against, which has historically required manually matching a standalone download of WebDriver to the appropriate version of Windows on your device.

So now WebDriver being a Windows Feature on Demand (FoD), which ensures that it’s always up to date automatically and also enables some new ways to get Microsoft WebDriver.

Steps

  • Enable Developer Mode which will install the appropriate version of WebDriver.

    Open Settings app > Go to Update & Security > For Developer and then select "Developer Mode".
    
  • You can also install a standalone version of WebDriver in one of two ways:

    • Search "Manage optional features" from Start, then select "Add a Feature", "WebDriver".
    • Install via DISM by running the following command in an elevated command prompt:

      DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0
      

Conclusion

Once you install MicrosoftWebDriver with the elevated command prompt it will be updated automatically and you won't have to mention the absolute path of the MicrosoftWebDriver binary through System.setProperty() anymore.


Reference

You can find a detailed discussion in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    An important thing to note: make sure to **not** install the Selenium.WebDriver.MicrosoftDriver package. I had followed the steps you outlined (I found them on Microsoft's website) but I was still getting errors saying the connection was forcibly closed. Remove the package solved the error. – Marc Levesque Aug 10 '20 at 19:40
  • @MarcLevesque Your comment should be pretty helpful to the community. Feel free to edit the answer and add this relevant information. – undetected Selenium Aug 10 '20 at 20:09