Switching to a window with no name
codeception
Solution
After searching around on the Selenium forum and some helpful prods from @Mark Rowlands, I got it to work using raw Selenium.
// before codeception v2.1.1, just typehint on \Webdriver
$I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
$handles=$webdriver->window_handles();
$last_window = end($handles);
$webdriver->focusWindow($last_window);
});
Returning back to the parent window was easy because I could just use Codeception's `switchToWindow` method:
$I->switchToWindow();
Problem
Using the Codeception testing framework and Selenium 2 module to test a website, I end up following a hyperlink that opens a new window with no name. As a result the `switchToWindow()` function will not work because it is trying to switch to the parent window (which I'm currently on). Without being able to switch to the new window I cannot perform any testing on it. ``` <a class="external" target="_blank" href="http://mylocalurl/the/page/im/opening"> View Live </a> ``` Using both Chrome and Firefox debugging tools I can confirm the new window doesn't have a name, and I cannot give it one because I cannot edit the HTML page I am working on. Ideally I would have changed the HTML to use javascript `onclick="window.open('http://mylocalurl/the/page/im/opening', 'myPopupWindow')` however this is not possible in my case. I've looked around on the Selenium forums without any clear method to tackle this problem, and Codeception doesn't appear to have much functionality around this.