Skip to content

Commit db5f926

Browse files
committed
Fixing Java tests
1 parent fcc6cb5 commit db5f926

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
import org.junit.jupiter.api.Test;
1717
import org.openqa.selenium.By;
1818
import org.openqa.selenium.WebElement;
19+
import org.openqa.selenium.bidi.webextension.ExtensionPath;
20+
import org.openqa.selenium.bidi.webextension.InstallExtensionParameters;
21+
import org.openqa.selenium.bidi.webextension.WebExtension;
1922
import org.openqa.selenium.chrome.ChromeDriver;
2023
import org.openqa.selenium.chrome.ChromeDriverService;
2124
import org.openqa.selenium.chrome.ChromeOptions;
@@ -58,13 +61,17 @@ public void setBrowserLocation() {
5861
@Test
5962
public void extensionOptions() {
6063
ChromeOptions options = getDefaultChromeOptions();
61-
Path path = Paths.get("src/test/resources/extensions/webextensions-selenium-example.crx");
62-
File extensionFilePath = new File(path.toUri());
64+
options.enableBiDi();
65+
options.addArguments("--remote-debugging-pipe");
66+
options.addArguments("--enable-unsafe-extension-debugging");
67+
driver = new ChromeDriver(options);
6368

64-
options.addExtensions(extensionFilePath);
65-
options.addArguments("--disable-features=DisableLoadExtensionCommandLineSwitch");
69+
Path path = Paths.get("src/test/resources/extensions/selenium-example");
70+
WebExtension extension = new WebExtension(driver);
71+
ExtensionPath extensionPath = new ExtensionPath(path.toString());
72+
InstallExtensionParameters parameters = new InstallExtensionParameters(extensionPath);
73+
extension.install(parameters);
6674

67-
driver = new ChromeDriver(options);
6875
driver.get("https://www.selenium.dev/selenium/web/blank.html");
6976
WebElement injected = driver.findElement(By.id("webextensions-selenium-example"));
7077
Assertions.assertEquals(

examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
import org.openqa.selenium.edge.EdgeDriver;
2222
import org.openqa.selenium.edge.EdgeDriverService;
2323
import org.openqa.selenium.edge.EdgeOptions;
24-
import org.openqa.selenium.logging.*;
24+
import org.openqa.selenium.logging.LogEntries;
25+
import org.openqa.selenium.logging.LogEntry;
26+
import org.openqa.selenium.logging.LogType;
27+
import org.openqa.selenium.logging.LoggingPreferences;
2528
import org.openqa.selenium.remote.service.DriverFinder;
2629

2730

@@ -116,7 +119,7 @@ public void logsToConsole() throws IOException {
116119
driver = new EdgeDriver(service);
117120

118121
String fileContent = new String(Files.readAllBytes(logLocation.toPath()));
119-
Assertions.assertTrue(fileContent.contains("Starting Microsoft Edge WebDriver"));
122+
Assertions.assertTrue(fileContent.contains("Starting msedgedriver"));
120123
}
121124

122125
@Test

0 commit comments

Comments
 (0)