Codeception – закрытые всплывающие всплески selemium test

Я тестирую простой поток с помощью Codeception с Selenium / FacebookWebdriver, где всплывающее окно закрывается в конце, что приводит к разрыву всего теста.

Код завершен (тест будет запущен) и воспроизведет ошибку. Я действительно отчаянный здесь, любые предложения будут очень высоко оценены.

Это ошибки, которые я получаю:

Сообщение об ошибке кода: [Facebook\WebDriver\Exception\NoSuchWindowException] Window not found. The browser window may have been closed. [Facebook\WebDriver\Exception\NoSuchWindowException] Window not found. The browser window may have been closed.

Выходное сообщение сервера Selenium: WARN - Exception: Window not found. The browser window may have been closed. WARN - Exception: Window not found. The browser window may have been closed.

Этот код воспроизводит проблему. Он состоит из 3 файлов .html (main.html, intermediate.html, popup.html), тестового файла (PopupCest.php) и файла конфигурации (selenium.suite.yml).

PopupCest.php

 <?php class PopupCest { public function popup(SeleniumTester $I) { $I->expectTo('Start on main page and click a link that opens a popup'); $I->amOnPage('/main.html'); $I->click('#main-link'); $I->expectTo('Interact with the popup window and click the final confirmation button'); $I->switchToNextTab(); $I->click('#final-confirmation-button'); $I->expectTo('Go back to intermediate window and let it do its magic'); $I->switchToPreviousTab(); $I->see('contents of this intermediate page'); $I->seeInCurrentUrl('intermediate.html'); } } 

selenium.suite.yml

 class_name: SeleniumTester modules: enabled: - WebDriver: url: http://localhost browser: firefox - \Helper\Selenium 

main.html

 <html> <head> <meta charset="utf-8"> <title>Main page - under my control</title> <meta name="description" content="Main page - under my control"> </head> <body> <h1>Main</h1> <p> After clicking this link, "intermediate page" url is received from a backend operation in reality. </p> <br> <a href="intermediate.html" id="main-link">Click here to open the popup</a> <br> </body> </html> 

intermediate.html

 <html> <head> <meta charset="utf-8"> <title>External - intermediate page</title> <meta name="description" content="Intermediate page outside of my control"> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> </head> <body> <h1>Intermediate</h1> <p> In reality, contents of this intermediate page is fully controlled by other party - a payment processor. <br> It only load a javascript that opens up a popup window where user enters his payment details. </p> <script type="text/javascript"> $(function() { var settings = "height=400,width=500,status=yes,dependent=no,resizable=yes"; popup = window.open('popup.html', 'dont_know_the_name_here', settings); if (popup != null) { popup.focus(); } }); </script> </body> </html> 

popup.html

 <html> <head> <meta charset="utf-8"> <title>External - popup</title> <meta name="description" content="Popup page outside of my control"> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> </head> <body> <h1>Popup</h1> <p> Contents of this page is fully controlled by other party - a payment processor. <br> This is where user enters his payment details. </p> <p> eg <i>"After you have finished your data input, click here to:"</i> <br> <a href="" id="final-confirmation-button">Confirm your payment</a> </p> <script type="text/javascript"> $(function() { $('#final-confirmation-button').on('click', function(e) { e.preventDefault(); window.close(); // <-- this breaks it all }); }); </script> </body> </html> 

Спасибо за помощь, Томас

Solutions Collecting From Web of "Codeception – закрытые всплывающие всплески selemium test"

Тестовый код кажется правильным, я подозреваю, что проблема связана с устаревшими версиями или, возможно, с драйвером Firefox.

Я протестировал ваш код с помощью chrome + chromedriver и, похоже, работает без проблем. Вот тестовое репо с инструкциями о том, как использовать изменения хромирования + требуемые конфигурации: https://github.com/henrikauppinen/codeception-popup-chromedriver

В общем, я бы посоветовал использовать Chrome для такого типа тестирования, если вы специально не тестируете Firefox или если это требование.