public function testCollection() { $browser = $this->getBrowser(true)->open($this->getUrl('index.php')); $count = count($browser->getWindows()->getAll()); $browser->element(By::linkText('Pop-up'))->click(); $this->assertCount($count + 1, $all = $browser->getWindows()->getAll()); $browser->element(By::linkText('Another page'))->click(); $orig = $browser->getWindows()->getCurrent(); $other = array_values(array_diff($all, array($orig)))[0]; $browser->getWindows()->focus($other); $this->assertContains('Welcome to sample website', $browser->getText()); $browser->getWindows()->closeCurrent(); $browser->getWindows()->focus($orig); $this->assertContains('You know... some other page', $browser->getText()); $browser->close(); }