Search code examples
javaseleniummavenwindows-10

Error using Selenium Chrome Webdriver with Java, Maven and Windows 10 - Access is Denied


Jan 13, 2021 8:29:16 AM org.openqa.selenium.os.OsProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "...\chromedriver.exe" (in directory "."): CreateProcess error=5, Access is denied)

When I attempt to run Selenium Webdriver on my Windows 10 machine using Maven, Google Chrome Browser and Java, I come across this message. I have checked the permissions and everything appears to be set up correctly:

enter image description hereenter image description here

What could be causing this Access denied issue?

EDIT: So that I can re-open this question, the above linked questions do NOT answer my problem, my problem is related to error code 5, Access Denied. (the linked questions appear to be related to Error code 1) Here's my code to prove my statement:

psf Logger logger = LogManager.getLogger(BrowserRunTime.class);
logger.info("*** Chrome Simulation(): default viewport");
String exePath = System.getProperty(USER_DIR) + "\\src\\main\\resources\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver", exePath);
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(chromeOptions);       
driver.get(browserMeta.getProperties().getProperty(DESKTOP_URL));
WebDriverWait wait = new WebDriverWait(driver, 10);

Solution

  • Typically, I managed to resolve the issue by restarting my PC, it just seemed to be a transient issue that resolves itself on a restart. If anyone has issues with Access Denied issues when you shouldn't; try restarting your PC first.