Unable to launch Edge browser through environmental variable | Selenium Forum
H
Harshad W Posted on 12/09/2020

Hi,

I am not able to launch the Edge browser using the Environment variables. The error says,

"The path to the driver executable must be set by the webdriver.edge.driver system property" Chrome and FF don't throw any errors. 

However, if I launch it using,

System.setProperty("webdriver.edge.driver","D:/drivers/msedgedriver.exe");

it gets launched without any issues. What is the reason behind this? I am using the following versions of Edge and EdgeDriver:

Edge Version 85.0.564.51

Edge driver x64 Version: 85.0.564.51 

I am using Win 8.1 x 64 bit machine. 

Thanks,

 


A
Ashish Replied on 15/09/2020

Did you add the path of web driver to the PATH Variable?

if yes, try restarting your machine.


H
Harshad W Replied on 26/09/2020

Yes, I did add the path to the PATH variable. 

Chrome and Mozilla browsers don't have a problem launching the browsers. Only Edge is throwing the error.

What can be the issue? It was working fine a few weeks ago.

 


A
Ashish Replied on 27/09/2020

Please paste the error here


H
Harshad W Replied on 27/09/2020

Here is the code:

package base;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeDriverService;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.ProfilesIni;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class TestBase {
	
	WebDriver driver;
	public WebDriver launchBrowser(String browser)
	{
		if(browser.equals("Chrome"))
		{
			System.setProperty(ChromeDriverService.CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true");
			ChromeOptions options = new ChromeOptions();
			options.addArguments("--disable-notifications");
			options.addArguments("ignore-certificate-errors");
			options.addArguments("--start-maximized");
			driver = new ChromeDriver(options);
		}
		else if(browser.equals("Firefox")){
			System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "log\\firefox.log");
			FirefoxOptions options = new FirefoxOptions();
			FirefoxProfile prof = new FirefoxProfile();
			prof.setPreference("dom.webnotifications.enabled", false); //this will turn off the notifications
			options.setProfile(prof);
			driver = new FirefoxDriver(options);
			driver.manage().window().maximize();
		}
			
		else if(browser.equals("Edge")){
			driver = new EdgeDriver();
			
		}
			
		else if(browser.equals("IE")){
			driver = new InternetExplorerDriver();
		}
		return driver;
	}

}



package login;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.testng.annotations.Test;

import base.TestBase;

public class LoginTest extends TestBase {
	@Test
	public void login(){
		WebDriver driver = launchBrowser("Edge");
		driver.get("https://www.linkedin.com/login?fromSignIn=true&trk=guest_homepage-basic_nav-header-signin");
		WebElement username = driver.findElement(By.id("username"));
		username.sendKeys("testuser.testing");
		driver.findElement(By.name("session_password")).sendKeys("123456");
		
	}

}

 


H
Harshad W Replied on 27/09/2020

Error

[RemoteTestNG] detected TestNG version 6.14.2
FAILED: login
java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.edge.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/MicrosoftWebDriver. The latest version can be downloaded from http://go.microsoft.com/fwlink/?LinkId=619687
at com.google.common.base.Preconditions.checkState(Preconditions.java:847)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:134)
at org.openqa.selenium.edge.EdgeDriverService.access$000(EdgeDriverService.java:37)
at org.openqa.selenium.edge.EdgeDriverService$Builder.findDefaultExecutable(EdgeDriverService.java:90)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:355)
at org.openqa.selenium.edge.EdgeDriverService.createDefaultService(EdgeDriverService.java:70)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:96)
at base.TestBase.launchBrowser(TestBase.java:40)
at login.LoginTest.login(LoginTest.java:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:580)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)


===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================



A
Ashish Replied on 30/09/2020

In base class:

You have not set edge driver path

else if(browser.equals("Edge")){
			driver = new EdgeDriver();
			
		}


H
Harshad W Replied on 30/09/2020

Beacuse I added the all drivers' exe folder path to the PATH variable. 

 

See the attached image. If I add the following line for Chrome driver and remove the rest of the part, it gets launched successfully. The issue is only with Edge driver.

if(browser.equals("Chrome"))

{
driver = new ChromeDriver();

}


H
Harshad W Replied on 04/10/2020

Hi, 

Any updates on this?


A
Ashish Replied on 04/10/2020

Looks weird

Can you upgrade your edge browser to latest version

And get the latest driver exe

Restart machine and check


Related Posts