@@ -269,6 +269,26 @@ public function i_swipe_in_the_app(string $direction, bool $hasLocator = false,
269269 $ this ->getSession ()->wait (300 );
270270 }
271271
272+ /**
273+ * Wait for a BBB room to start.
274+ *
275+ * @When I wait for the BigBlueButton room to start
276+ */
277+ public function i_wait_bbb_room_to_start () {
278+ $ windowNames = $ this ->getSession ()->getWindowNames ();
279+
280+ $ this ->getSession ()->switchToWindow (array_pop ($ windowNames ));
281+ $ this ->spin (function ($ context ) {
282+ $ joinmodal = $ context ->getSession ()->getPage ()->find ('css ' , 'div[role="dialog"][aria-label="How would you like to join the audio?"] ' );
283+
284+ if ($ joinmodal ) {
285+ return true ;
286+ }
287+
288+ throw new DriverException ('BBB room not started ' );
289+ }, false , 30 );
290+ }
291+
272292 /**
273293 * Check if elements are selected in the app.
274294 *
@@ -646,24 +666,46 @@ public function i_press_in_the_app(string $locator) {
646666 /**
647667 * Performs a pull to refresh gesture.
648668 *
649- * @When I pull to refresh in the app
669+ * @When /^ I pull to refresh (?:until I find (".+") )? in the app$/
650670 * @throws DriverException If the gesture is not available
651671 */
652- public function i_pull_to_refresh_in_the_app () {
653- $ this -> spin ( function () {
654- $ result = $ this -> runtime_js ( ' pullToRefresh() ' );
672+ public function i_pull_to_refresh_in_the_app (? string $ locator = null ) {
673+ $ timeout = 0 ;
674+ $ startTime = time ( );
655675
656- if ($ result !== 'OK ' ) {
657- throw new DriverException ('Error pulling to refresh - ' . $ result );
676+ if (!is_null ($ locator )) {
677+ $ timeout = 60 ;
678+ $ locator = $ this ->parse_element_locator ($ locator );
679+ }
680+
681+ do {
682+ $ this ->spin (function () {
683+ $ result = $ this ->runtime_js ('pullToRefresh() ' );
684+
685+ if ($ result !== 'OK ' ) {
686+ throw new DriverException ('Error pulling to refresh - ' . $ result );
687+ }
688+
689+ return true ;
690+ });
691+
692+ $ this ->wait_for_pending_js ();
693+
694+ // Wait for UI to settle after refreshing.
695+ $ this ->getSession ()->wait (300 );
696+
697+ if (is_null ($ locator )) {
698+ return ;
658699 }
659700
660- return true ;
661- });
701+ $ result = $ this ->runtime_js ("find( $ locator) " );
662702
663- $ this ->wait_for_pending_js ();
703+ if ($ result === 'OK ' ) {
704+ return ;
705+ }
706+ } while ($ timeout > (time () - $ startTime ));
664707
665- // Wait for UI to settle after refreshing.
666- $ this ->getSession ()->wait (300 );
708+ throw new DriverException ('Error finding element after PTR - ' . $ result );
667709 }
668710
669711 /**
0 commit comments