Skip to content

Microsoft Edge with High DPI Settings Fails to Load Pages with Selenium WebDriver #198

Open
@CTsakurada

Description

@CTsakurada

Environment Detail

  • Java: 21
  • Selenium: selenium-java 4.33.0
  • Microsoft Edge Driver: 137.0.3296.52
  • OS: Windows 11
  • Microsoft Edge High DPI Setting: ON (Source: System)
  • maven-assembly-plugin 3.6.0

Issue Description

When Microsoft Edge's High DPI setting is turned ON, Selenium WebDriver launches the browser but fails to load any pages. However, when the High DPI setting is turned OFF, everything works normally. This issue doesn't occur with Google Chrome browser with High DPI settings enabled.

  • When I run the jar file with High DPI settings disabled for Microsoft Edge, the browser launches and displays the page correctly.

  • When I enable High DPI settings (System) for Microsoft Edge and run the same jar file, the browser launches but no page is displayed.

  • Google Chrome works correctly even with High DPI settings enabled.

  • I have tried killing all Edge processes before running the test and have confirmed that the issue is specifically related to the High DPI settings.

  • I tested with multiple Selenium versions including older ones, but the same problem persists across all versions.

  • I was also able to reproduce the same issue using Edge WebDriver version 136.xx, so this is not limited to the latest version.

To clarify, I am not trying to apply High DPI settings to Microsoft Edge itself. Rather, I want to ensure that my own Java application (originally a JAR, converted into an EXE) runs with proper High DPI scaling. When using ChromeDriver, the application displays correctly under high DPI settings. However, when using EdgeDriver, the same application does not scale properly, even though the same DPI configuration is applied.

Reproducible Code

package selenium;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.edge.EdgeDriver;

public class EdgeDriverSample {

	public static void main(String[] args) throws Exception {
		
		System.setProperty("webdriver.edge.driver", "C:/tools/msedgedriver.exe");
		EdgeDriver driver = new EdgeDriver();

		try {
			driver.navigate().to("https://bing.com");
			System.out.println(System.getProperty("webdriver.edge.driver"));
			WebElement element = driver.findElement(By.id("sb_form_q"));
			element.sendKeys("WebDriver");
			element.submit();

			Thread.sleep(5000);
		} finally {
			driver.quit();
		}
	}
}

Debugging Logs

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created: probably user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
Host info: host: 'xxx', ip: 'xxx'
Build info: version: '4.33.0', revision: '2c6aaad03a'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '21.0.6'
Driver info: org.openqa.selenium.edge.EdgeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: MicrosoftEdge, ms:edgeOptions: {args: [], extensions: []}}]}]
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:114)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:75)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:61)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:187)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:216)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:174)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:544)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:173)
        at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:110)
        at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:60)
        at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:56)
        at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:48)
        at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:44)
        at selenium.EdgeDriverSample.main(EdgeDriverSample.java:12)

Question

  1. Could this be a compatibility issue between Selenium and Microsoft Edge with High DPI settings enabled?
  2. Is there a way to make Selenium work with Microsoft Edge when High DPI settings are ON?
  3. Are there any specific EdgeOptions or command-line arguments that could resolve this issue?

Supplement

Settings

To configure High DPI settings for Microsoft Edge (or any other app), follow these steps:

  • Right-click the desktop shortcut for Microsoft Edge and select "Properties".
  • Go to the "Compatibility" tab.
  • Click on "Change high DPI settings".
  • In the window that appears:
  • Under "High DPI scaling override", check the box "Override high DPI scaling behavior."
  • For "Scaling performed by:", select "System" from the dropdown.

This helps resolve any blurriness or scaling issues on high-resolution displays.

Here is a screenshot of the settings in Japanese (for reference), but the steps above reflect the equivalent English version.

Image

Reference from Selenium Team

I raised this issue in the Selenium GitHub repository, and the maintainers pointed out that it is likely an issue with EdgeWebDriver, not Selenium itself.

See their response here: SeleniumHQ/issues/#15815

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions