Skip to content

Commit f1eac5f

Browse files
committed
add firefox test for BiDi multiple sessions
1 parent 413a130 commit f1eac5f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

java/test/org/openqa/selenium/firefox/FirefoxDriverConcurrentTest.java

+32
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.Random;
2525
import org.junit.jupiter.api.Test;
2626
import org.openqa.selenium.By;
27+
import org.openqa.selenium.bidi.BiDi;
2728
import org.openqa.selenium.ParallelTestRunner;
2829
import org.openqa.selenium.ParallelTestRunner.Worker;
2930
import org.openqa.selenium.WebDriver;
@@ -164,4 +165,35 @@ void shouldBeAbleToUseTheSameProfileMoreThanOnce() {
164165
if (two != null) two.quit();
165166
}
166167
}
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+
}
167199
}

0 commit comments

Comments
 (0)