|
24 | 24 | import java.util.Random;
|
25 | 25 | import org.junit.jupiter.api.Test;
|
26 | 26 | import org.openqa.selenium.By;
|
| 27 | +import org.openqa.selenium.bidi.BiDi; |
27 | 28 | import org.openqa.selenium.ParallelTestRunner;
|
28 | 29 | import org.openqa.selenium.ParallelTestRunner.Worker;
|
29 | 30 | import org.openqa.selenium.WebDriver;
|
@@ -164,4 +165,35 @@ void shouldBeAbleToUseTheSameProfileMoreThanOnce() {
|
164 | 165 | if (two != null) two.quit();
|
165 | 166 | }
|
166 | 167 | }
|
| 168 | + |
| 169 | + @Test |
| 170 | + void multipleFirefoxInstancesWithBiDiEnabledCanRunSimultaneously() { |
| 171 | + // Create two Firefox instances with BiDi enabled |
| 172 | + FirefoxOptions options1 = new FirefoxOptions().enableBiDi(); |
| 173 | + FirefoxOptions options2 = new FirefoxOptions().enableBiDi(); |
| 174 | + |
| 175 | + FirefoxDriver driver1; |
| 176 | + FirefoxDriver driver2; |
| 177 | + |
| 178 | + // Start the first Firefox instance |
| 179 | + driver1 = new FirefoxDriver(options1); |
| 180 | + BiDi biDi1 = driver1.getBiDi(); |
| 181 | + assertThat(biDi1).isNotNull(); |
| 182 | + |
| 183 | + // Extract the BiDi websocket URL and port for the first instance |
| 184 | + String webSocketUrl1 = (String) driver1.getCapabilities().getCapability("webSocketUrl"); |
| 185 | + String port1 = webSocketUrl1.replaceAll("^ws://[^:]+:(\\d+)/.*$", "$1"); |
| 186 | + |
| 187 | + // Start the second Firefox instance |
| 188 | + driver2 = new FirefoxDriver(options2); |
| 189 | + BiDi biDi2 = driver2.getBiDi(); |
| 190 | + assertThat(biDi2).isNotNull(); |
| 191 | + |
| 192 | + // Extract the BiDi websocket URL and port for the second instance |
| 193 | + String webSocketUrl2 = (String) driver2.getCapabilities().getCapability("webSocketUrl"); |
| 194 | + String port2 = webSocketUrl2.replaceAll("^ws://[^:]+:(\\d+)/.*$", "$1"); |
| 195 | + |
| 196 | + // Verify that the ports are different |
| 197 | + assertThat(port1).isNotEqualTo(port2); |
| 198 | + } |
167 | 199 | }
|
0 commit comments