I have a very simple acceptance test using codeaptions and WebDriver (it's a hybridath ("login through some" * some) Social network).
Code:
$ i = $ i = new acceptor ($ scenario); $ I- & gt; ('Register using VK account (hybridauth) and check the list of friends loaded'); $ I- & gt; AmOnPage ('/'); $ I- & gt; See ('VKontakte'); $ I- & gt; Click ("VKontakte"); $ __ Handles = Faucet; $ I- & gt; ExecuteInSelenium (Function (\ WebDriver $ webdriver) {Global handles $ __, $ __ handles = $ webdriver- & gt; getWindowHandles (); $ webdriver-> switchTo () - & gt; window (end ($ __ handles ));}); // VK popup load codecept_debug ($ I-> grabTextFrom ('# install_allow')); $ I- & gt; SeeElement ('box_login.'); $ I- & gt; Bharfeld ('email', '******'); $ I- & gt; Bharfeld ('Pass', '******'); $ I- & gt; ($ I- & gt; grabTextFrom ('# install_allow')); $ I- & gt; DontSeeElement ('oauth_error.'); The line is successfully implemented in this test, but at the end, Codeception throws a "no window" complaint about an exception:
[NoSuchWindowException] window found. The browser window may close. Create information: Version: '2.45.0', Modification: '5017cb8', Time: '2015-02-26 23:59:50' System Information: Host: '***', IP: '***', Os.name: 'linux', os.arch: 'amd64', os.version: '3.2.0-4-amd64', java.version: '1.7.0_65' driver information: driver.version: unknown
The question is how to run this test easily, how to manage this situation? $ I-> switchToWindow ();
does not help.
*** Update: Resolved. The answer is simple: $ I-> DontSeeElement ('.aauth_error');
is removed when the window closes first so we need to switch the window first, and only then there is some claim.
We had the same problem authentication with OAuth2. We inject javascript to give a known name to the main window, so we can switch popup and Webdriver lost its context after the window disappears. Then it is a full user step method to handle a popup login hh
$ i - & gt; Executed JS ('old_window_name = windowname; window; name =' menu window ');
public function openLoginPopup () {$ I = $ this; $ I- & gt; AmOnPage (\ MainMenuPage :: $ url); $ I- & gt; DoWait (); $ I- & gt; Execution js ('old_window_name = windowname; window; name = "mainwindows"'); $ I- & gt; Click (\ MainMenuPage :: $ loginButtonLocator); $ I- & gt; SwitchToWindow (\ LoginPage :: $ windowName); } Public function fillloginform ($ username, $ password) {$ I = $ this; $ I- & gt; Bharflild ('_username', $ username); $ I- & gt; Fill field ('_ password', $ password); } Public event submitLoginData () {$ I = $ this; $ I- & gt; Click (\ LoginPage :: $ loginButtonLocator); $ I- & gt; SwitchToWindow ('MainWindow'); $ I- & gt; ExecuteJS ('window.name = old_window_name'); }