|
8 | 8 | import java.nio.file.Path; |
9 | 9 | import java.nio.file.Paths; |
10 | 10 | import java.util.List; |
| 11 | +import java.util.Map; |
11 | 12 | import java.util.logging.Level; |
12 | 13 | import java.util.regex.Pattern; |
13 | 14 | import org.junit.jupiter.api.AfterEach; |
14 | 15 | import org.junit.jupiter.api.Assertions; |
15 | 16 | import org.junit.jupiter.api.Test; |
16 | 17 | import org.openqa.selenium.By; |
17 | 18 | import org.openqa.selenium.WebElement; |
18 | | -import org.openqa.selenium.chrome.ChromeDriver; |
19 | 19 | import org.openqa.selenium.chromium.ChromiumDriverLogLevel; |
20 | 20 | import org.openqa.selenium.chromium.ChromiumNetworkConditions; |
21 | 21 | import org.openqa.selenium.edge.EdgeDriver; |
22 | 22 | import org.openqa.selenium.edge.EdgeDriverService; |
23 | 23 | import org.openqa.selenium.edge.EdgeOptions; |
24 | | -import org.openqa.selenium.logging.LogEntries; |
25 | | -import org.openqa.selenium.logging.LogType; |
26 | | -import org.openqa.selenium.logging.LoggingPreferences; |
| 24 | +import org.openqa.selenium.logging.*; |
27 | 25 | import org.openqa.selenium.remote.service.DriverFinder; |
28 | 26 |
|
| 27 | + |
| 28 | + |
29 | 29 | public class EdgeTest extends BaseTest { |
30 | 30 | @AfterEach |
31 | 31 | public void clearProperties() { |
@@ -217,4 +217,40 @@ public void setNetworkConditions() { |
217 | 217 | ((EdgeDriver) driver).deleteNetworkConditions(); |
218 | 218 | driver.quit(); |
219 | 219 | } |
| 220 | + |
| 221 | + @Test |
| 222 | + public void castFeatures() { |
| 223 | + EdgeDriver driver = new EdgeDriver(); |
| 224 | + |
| 225 | + List<Map<String, String>> sinks = driver.getCastSinks(); |
| 226 | + if (!sinks.isEmpty()) { |
| 227 | + String sinkName = sinks.get(0).get("name"); |
| 228 | + driver.startTabMirroring(sinkName); |
| 229 | + driver.stopCasting(sinkName); |
| 230 | + } |
| 231 | + |
| 232 | + driver.quit(); |
| 233 | + } |
| 234 | + |
| 235 | + @Test |
| 236 | + public void getBrowserLogs() { |
| 237 | + EdgeDriver driver = new EdgeDriver(); |
| 238 | + driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); |
| 239 | + WebElement consoleLogButton = driver.findElement(By.id("consoleError")); |
| 240 | + consoleLogButton.click(); |
| 241 | + |
| 242 | + LogEntries logs = driver.manage().logs().get(LogType.BROWSER); |
| 243 | + |
| 244 | + // Assert that at least one log contains the expected message |
| 245 | + boolean logFound = false; |
| 246 | + for (LogEntry log : logs) { |
| 247 | + if (log.getMessage().contains("I am console error")) { |
| 248 | + logFound = true; |
| 249 | + break; |
| 250 | + } |
| 251 | + } |
| 252 | + |
| 253 | + Assertions.assertTrue(logFound, "No matching log message found."); |
| 254 | + driver.quit(); |
| 255 | + } |
220 | 256 | } |
0 commit comments