22
33import java .io .File ;
44import java .io .IOException ;
5+ import java .time .Duration ;
56import java .util .HashMap ;
67import java .util .Map ;
78import java .util .Map .Entry ;
8- import java .util .concurrent .TimeUnit ;
99
1010import org .apache .commons .io .FileUtils ;
11- import org .apache .commons .lang .StringUtils ;
11+ import org .apache .commons .lang3 .StringUtils ;
1212import org .junit .Assert ;
1313import org .junit .jupiter .api .AfterEach ;
1414import org .junit .jupiter .api .BeforeAll ;
2020import org .openqa .selenium .By ;
2121import org .openqa .selenium .Dimension ;
2222import org .openqa .selenium .WebDriver ;
23+ import org .openqa .selenium .chrome .ChromeDriver ;
24+ import org .openqa .selenium .chrome .ChromeOptions ;
2325import org .openqa .selenium .support .ui .ExpectedCondition ;
2426import org .openqa .selenium .support .ui .ExpectedConditions ;
27+ import org .openqa .selenium .support .ui .WebDriverWait ;
2528import org .slf4j .Logger ;
2629import org .slf4j .LoggerFactory ;
2730
28- import io .github .bonigarcia .seljup .SeleniumExtension ;
31+ import io .github .bonigarcia .seljup .SeleniumJupiter ;
2932import io .github .bonigarcia .wdm .WebDriverManager ;
3033import io .openvidu .java .client .OpenVidu ;
3134import io .openvidu .java .client .OpenViduHttpException ;
3235import io .openvidu .java .client .OpenViduJavaClientException ;
3336import io .openvidu .java .client .Recording ;
3437import io .openvidu .java .client .Recording .OutputMode ;
35- import io .openvidu .test .browsers .BrowserUser ;
36- import io .openvidu .test .browsers .ChromeUser ;
3738import ws .schild .jave .EncoderException ;
3839import ws .schild .jave .MultimediaInfo ;
3940import ws .schild .jave .MultimediaObject ;
4849 * @author Pablo Fuente (pablofuenteperez@gmail.com)
4950 */
5051@ DisplayName ("E2E tests for openvidu-java-recording" )
51- @ ExtendWith (SeleniumExtension .class )
52+ @ ExtendWith (SeleniumJupiter .class )
5253@ RunWith (JUnitPlatform .class )
5354public class AppTestE2e {
5455
5556 private static final Logger log = LoggerFactory .getLogger (AppTestE2e .class );
5657
5758 static String OPENVIDU_SECRET = "MY_SECRET" ;
58- static String OPENVIDU_URL = "https ://localhost:4443/" ;
59+ static String OPENVIDU_URL = "http ://localhost:4443/" ;
5960 static String APP_URL = "https://localhost:5000/" ;
6061 static int NUMBER_OF_ATTEMPTS = 10 ;
6162 static int RECORDING_DURATION = 5 ; // seconds
6263 static double DURATION_THRESHOLD = 10.0 ; // seconds
6364
6465 static String RECORDING_PATH = "/opt/openvidu/recordings/" ;
6566
66- private BrowserUser user ;
67+ private WebDriver driver ;
68+ private WebDriverWait waiter ;
6769 private static OpenVidu OV ;
6870
6971 boolean deleteRecordings = true ;
7072
7173 @ BeforeAll ()
7274 static void setupAll () {
7375
74- WebDriverManager .chromedriver ().setup ();
76+ // Let WebDriverManager auto-detect browser version and download matching driver
77+ WebDriverManager .chromedriver ().browserVersionDetectionCommand ("/opt/google/chrome/chrome --version" ).setup ();
7578
7679 String appUrl = System .getProperty ("APP_URL" );
7780 if (appUrl != null ) {
@@ -162,13 +165,22 @@ void dispose() {
162165 log .error ("Error listing recordings: {}" , e2 .getMessage ());
163166 }
164167 }
165- this .user .dispose ();
168+ if (this .driver != null ) {
169+ this .driver .quit ();
170+ }
166171 }
167172
168173 void setupBrowser () {
169- user = new ChromeUser ("TestUser" , 20 , false );
170- user .getDriver ().manage ().timeouts ().setScriptTimeout (20 , TimeUnit .SECONDS );
171- user .getDriver ().manage ().window ().setSize (new Dimension (1920 , 1080 ));
174+ ChromeOptions options = new ChromeOptions ();
175+ options .addArguments ("--use-fake-ui-for-media-stream" );
176+ options .addArguments ("--use-fake-device-for-media-stream" );
177+ options .addArguments ("--ignore-certificate-errors" );
178+ options .addArguments ("--no-sandbox" );
179+ options .addArguments ("--disable-dev-shm-usage" );
180+ driver = new ChromeDriver (options );
181+ waiter = new WebDriverWait (driver , Duration .ofSeconds (20 ));
182+ driver .manage ().timeouts ().scriptTimeout (Duration .ofSeconds (20 ));
183+ driver .manage ().window ().setSize (new Dimension (1920 , 1080 ));
172184 }
173185
174186 @ Test
@@ -183,26 +195,26 @@ void composedRecordingTest() throws Exception {
183195 String videoFile = "" ;
184196
185197 setupBrowser ();
186- user . getDriver () .get (APP_URL );
198+ driver .get (APP_URL );
187199
188- user . getDriver () .findElement (By .id ("join-btn" )).click ();
200+ driver .findElement (By .id ("join-btn" )).click ();
189201 waitUntilEvents ("connectionCreated" , "videoElementCreated" , "accessAllowed" , "streamCreated" , "streamPlaying" );
190202
191- user . getDriver () .findElement (By .id ("has-video-checkbox" )).click ();
203+ driver .findElement (By .id ("has-video-checkbox" )).click ();
192204
193205 while (durationDifferenceAcceptable && (i < NUMBER_OF_ATTEMPTS )) {
194206
195207 log .info ("----------" );
196208 log .info ("Attempt {}" , i + 1 );
197209 log .info ("----------" );
198210
199- user . getDriver () .findElement (By .id ("buttonStartRecording" )).click ();
211+ driver .findElement (By .id ("buttonStartRecording" )).click ();
200212
201213 waitUntilEvents ("recordingStarted" );
202214
203215 Thread .sleep (RECORDING_DURATION * 1000 );
204216
205- user . getDriver () .findElement (By .id ("buttonStopRecording" )).click ();
217+ driver .findElement (By .id ("buttonStopRecording" )).click ();
206218 waitUntilEvents ("recordingStopped" );
207219
208220 Recording rec = OV .listRecordings ().get (0 );
@@ -247,9 +259,9 @@ void composedRecordingTest() throws Exception {
247259 }
248260
249261 private void waitUntilEvents (String ... events ) {
250- user . getWaiter () .until (eventsToBe (events ));
251- user . getDriver () .findElement (By .id ("clear-events-btn" )).click ();
252- user . getWaiter () .until (ExpectedConditions .textToBePresentInElementLocated (By .id ("textarea-events" ), "" ));
262+ waiter .until (eventsToBe (events ));
263+ driver .findElement (By .id ("clear-events-btn" )).click ();
264+ waiter .until (ExpectedConditions .textToBePresentInElementLocated (By .id ("textarea-events" ), "" ));
253265 }
254266
255267 private ExpectedCondition <Boolean > eventsToBe (String ... events ) {
0 commit comments