What can I do to solve this problem
? Please help me. Thank you.
What happened?I have a java project with dependencies
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.22.0</version>
</dependency>
Environment
JDK17
Windows 11
Edgebrowser: 106.0.1370.86
I packaged it using the following method to avoid dependency conflicts in another project.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>org.openqa.selenium</pattern>
<shadedPattern>link-download.org.openqa.selenium</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
My main function to excute.
public void downloadFileThroughUrl() throws InterruptedException {
System.setProperty("webdriver.edge.driver", System.getProperty("user.dir") + File.separator + "MicrosoftWebDriver.exe");
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.addArguments("--headless");
Map<String, Object> settings = new HashMap<>();
settings.put("download.default_directory", System.getProperty("user.dir"));
settings.put("plugins.always_open_pdf_externally", true);
settings.put("download.prompt_for_download",false);
settings.put("profile.default_content_settings.popups",0);
settings.put("safebrowsing.enabled",true);
WebDriver driver = null;
try {
edgeOptions.setExperimentalOption("prefs",settings);
driver = new EdgeDriver(edgeOptions);
driver.get("your valid download link");
Thread.sleep(10000);
System.out.println("Download successfully.");
} catch (Exception e) {
e.printStackTrace();
} finally {
if(driver != null){
driver.quit();
}
}
}
Jar file
link-download-1.0-SNAPSHOT.zip
How can we reproduce the issue?In a new project, depending on this JAR file, and calling it using the following method:
DownloadFileByLink downloadFileByLink = new DownloadFileByLink();
downloadFileByLink.downloadFileThroughUrl();
Will appear [[java.lang.IllegalArgumentException: Unknown HttpClient factory jdk-http-client] when creating new driver.
Relevant log outputCaused by: java.lang.IllegalArgumentException: Unknown HttpClient factory jdk-http-client
at link-download.org.openqa.selenium.remote.http.HttpClient$Factory.create(HttpClient.java:57)
at link-download.org.openqa.selenium.remote.http.HttpClient$Factory.createDefault(HttpClient.java:74)
at link-download.org.openqa.selenium.remote.HttpCommandExecutor$DefaultClientFactoryHolder.<clinit>(HttpCommandExecutor.java:56)
... 17 more
Operating SystemWindows 11
Selenium version4.22.0
What are the browser(s) and version(s) where you see this issue?Edgebrowser: 106.0.1370.86
What are the browser driver(s) and version(s) where you see this issue?EdgeDriver
Are you using Selenium Grid?NO