'How to handle browser window or tab using Behat and Mink PHP
I have test that click on link and then new browser window open and in new browser window I need to check some elements are present. How to switch to new Browser window that was opened using BEHAT/MINK?
Solution 1:[1]
Just in case this helps anyone, the window names are an array. So, using Igor's answer, $windowNames[1] is the 2nd tab, [2] would be a 3rd, and so fourth. If you are wondering how to go back to the first tab after this, simply remove the 'if' block (or check if at least 1 window exists) from Igor's answer and make a new function like so:
/**
* @Given I go to the first tab
*/
public function goToFirstTab()
{
$windowNames = $this->getSession()->getWindowNames();
$this->getSession()->switchToWindow($windowNames[0]);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DORRITO |
