2

I'm new to using Selenium, and I'm just starting with a simple script to open Edge and go to google:

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;

public class openEdge
{
   public static void main(String[] args)
  {
    System.setProperty("webdriver.edge.driver","E:\\Program Files 
    (x86)\\Microsoft Web Driver\\MicrosoftWebDriver.exe");

    WebDriver driver = new EdgeDriver();
    System.out.println("here");
    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    driver.get("https://www.google.com");
  }
}

When I run this, Edge opens successfully, but it seems to fail after creating the Webdriver instance (ie. doesn't print "here"). This is the error I get:

Exception in thread "main" org.openqa.selenium.NoSuchSessionException: null (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 358 milliseconds

Followed by Build and system info then a long list of driver info for the EdgeDriver. I've added dependencies to selenium client and server jars. Any help would be appreciated!

EDIT: Build, system and driver info as requested. I notice now that the build info is all unknown, I'm guessing that has something to do with it. I'll try re-downloading all my dependencies:

Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'myname', ip: 'myip', os.name: 'Windows 10', 
os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: driver.version: EdgeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$22(ProtocolHandshake.java:365)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:368)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:150)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:139)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:96)
at openEdge.openEdge.main(openEdge.java:16)
HSskillet
  • 63
  • 6
  • IMO for further analysis we need to see the exact `Build and system info then a long list of driver info for the EdgeDriver` from your console. – undetected Selenium Aug 09 '17 at 09:32

3 Answers3

1

Download latest jars of selenium webdriver(selenium server and selenium client binding).

http://docs.seleniumhq.org/download/

Download latest edge .exe from below path

https://download.microsoft.com/download/3/4/2/342316D7-EBE0-4F10-ABA2-AE8E0CDF36DD/MicrosoftWebDriver.exe

this code is working fine in my side :-

System.setProperty("webdriver.edge.driver","D:\\Workspace\\FluentWaitTest\\src\\lib\\MicrosoftWebDriver.exe");

WebDriver driver = new EdgeDriver();
System.out.println("here");
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get("https://www.google.com");
  driver.findElement(By.id("lst-ib")).sendKeys("selenium");
  driver.manage().window().maximize();
  List<WebElement> print = driver.findElements(By.xpath("//div[@class='sbqs_c']"));
  System.out.println(print.size());
  for ( WebElement we: print) { 
        System.out.println(we.getText());
    }
  }
Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
1

I ended up having the wrong WebDriver release installed for my OS build (got it from a link in a tutorial...). Installed the correct one for my build, and it works fine now. Thanks for the help.

HSskillet
  • 63
  • 6
0

MicroSoftWebDriver.exe (for Edge) should be compatible with the version of Microsoft Edge you are testing against.

Previously, above mentioned answers were correct & required us to manually download according to the appropriate version of OS. However, from last year, Microsoft edge driver is now distributed as a part of the OS

Steps to follow:-

  1. Go to Settings
  2. Click on "add or remove programs" to land on Apps & features
  3. Click on "Manage optional features"
  4. Click on the button - "Add a feature"
  5. Search for Microsoft Web Driver & Install

Now, since in our selenium tests we need to refer to the exact location of ".exe" file.

  1. Go to 'C:\Windows\SysWOW64' folder location
  2. You'll find "MicrosoftWebDriver.exe"

You can copy it at the location you are referring to your browser drivers from.

If you are interested to go into details, refer to this link - https://blogs.windows.com/msedgedev/2018/06/14/webdriver-w3c-recommendation-feature-on-demand/#Rg8g2hRfjBQQVRXy.97

Manny
  • 134
  • 2
  • 15