File tree Expand file tree Collapse file tree
tests/aik099/PHPUnit/Integration Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212
1313
1414use aik099 \PHPUnit \BrowserTestCase ;
15+ use Behat \Mink \Exception \DriverException ;
16+ use Behat \Mink \Session ;
1517
1618abstract class BrowserStackAwareTestCase extends BrowserTestCase
1719{
@@ -27,6 +29,32 @@ abstract class BrowserStackAwareTestCase extends BrowserTestCase
2729 ),
2830 );
2931
32+ /**
33+ * Visit specified URL and automatically start session if not already running.
34+ *
35+ * @param Session $session Session.
36+ * @param string $url Url of the page.
37+ *
38+ * @return void
39+ * @throws DriverException
40+ */
41+ protected function openPageWithBackoff (Session $ session , $ url )
42+ {
43+ try {
44+ $ session ->visit ($ url );
45+ }
46+ catch ( DriverException $ e ) {
47+ if ( strpos ($ e ->getMessage (), '[BROWSERSTACK_QUEUE_SIZE_EXCEEDED] ' ) !== false ) {
48+ sleep (30 );
49+ $ this ->openPageWithBackoff ($ session , $ url );
50+
51+ return ;
52+ }
53+
54+ throw $ e ;
55+ }
56+ }
57+
3058 /**
3159 * @before
3260 */
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class IsolatedSessionStrategyTest extends BrowserStackAwareTestCase
3737 public function testOne ()
3838 {
3939 $ session = $ this ->getSession ();
40- $ session -> visit ( 'https://www.google.com ' );
40+ $ this -> openPageWithBackoff ( $ session , 'https://www.google.com ' );
4141
4242 $ this ->assertTrue (true );
4343 }
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class SharedSessionStrategyTest extends BrowserStackAwareTestCase
3737 public function testOpensPage ()
3838 {
3939 $ session = $ this ->getSession ();
40- $ session -> visit ( 'https://www.google.com ' );
40+ $ this -> openPageWithBackoff ( $ session , 'https://www.google.com ' );
4141
4242 $ this ->assertTrue (true );
4343 }
@@ -57,7 +57,7 @@ public function testUsesOpenedPage()
5757 public function testOpensPopups ()
5858 {
5959 $ session = $ this ->getSession ();
60- $ session -> visit ( 'https://the-internet.herokuapp.com/windows ' );
60+ $ this -> openPageWithBackoff ( $ session , 'https://the-internet.herokuapp.com/windows ' );
6161
6262 $ page = $ session ->getPage ();
6363 $ page ->clickLink ('Click Here ' );
You can’t perform that action at this time.
0 commit comments