Codeception / module-webdriver

WebDriver module for Codeception
MIT License
36 stars 25 forks source link

Add waitForPopup() function #42

Open connorshea opened 5 years ago

connorshea commented 5 years ago

What are you trying to achieve?

I'm trying to use seeInPopup after pressing a button that activates a popup. Unfortunately, the popup doesn't show up immediately, since it has to wait for the backend to respond, and depending on the machine running the tests it could take anywhere from half a second to a few seconds.

This means we end up just waiting a few seconds instead, which wastes time on a faster machine:

$I->click('Test connection');
$I->wait(5);
$I->seeInPopup('Connection successful.');

I'd rather avoid increasing the 'smart wait' value, if possible.

Ideally, the code would look like this:

$I->click('Test connection');
$I->waitForPopup('Connection successful.');

Details

behat/gherkin                       v4.6.0             Gherkin DSL parser for PHP 5.3
behat/transliterator                v1.2.0             String transliterator
browserstack/browserstack-local     v1.1.0             PHP bindings for BrowserStack Local
codeception/codeception             3.0.0              BDD-style testing framework
codeception/phpunit-wrapper         6.0.16             PHPUnit classes used by Codeception
codeception/stub                    2.1.0              Flexible Stub wrapper for PHPUnit's Mock Builder
composer/semver                     1.5.0              Semver library that offers utilities, version constraint p...
composer/xdebug-handler             1.3.3              Restarts a process without xdebug.
consolidation/annotated-command     2.12.0             Initialize Symfony Console commands from annotated command...
consolidation/config                1.2.1              Provide configuration services for a commandline tool.
consolidation/log                   1.1.1              Improved Psr-3 / Psr\Log logger based on Symfony Console c...
consolidation/output-formatters     3.4.1              Format text by applying transformations provided by plug-i...
consolidation/robo                  1.4.9              Modern task runner
consolidation/self-update           1.1.5              Provides a self:update command for Symfony Console applica...
container-interop/container-interop 1.2.0              Promoting the interoperability of container objects (DIC, ...
defuse/php-encryption               v2.2.1             Secure PHP Encryption Library
dflydev/dot-access-data             v1.1.0             Given a deep data structure, access data by dot notation.
doctrine/annotations                v1.4.0             Docblock Annotations Parser
doctrine/instantiator               1.0.5              A small, lightweight utility to instantiate objects in PHP...
doctrine/lexer                      1.0.2              PHP Doctrine Lexer parser library that can be used in Top-...
elasticsearch/elasticsearch         v5.4.0             PHP Client for Elasticsearch
ezyang/htmlpurifier                 v4.10.0            Standards compliant HTML filter written in PHP
facebook/webdriver                  1.6.0              A PHP client for Selenium WebDriver
filp/whoops                         2.3.1              php error handling for cool kids
firebase/php-jwt                    v5.0.0             A simple library to encode and decode JSON Web Tokens (JWT...
flow/jsonpath                       0.4.0              JSONPath implementation for parsing, searching and flatten...
friendsofphp/php-cs-fixer           v2.15.1            A tool to automatically fix PHP code style
fzaninotto/faker                    v1.8.0             Faker is a PHP library that generates fake data for you.
google/apiclient                    v2.2.2             Client library for Google APIs
google/apiclient-services           v0.97              Client library for Google APIs
google/auth                         v1.5.1             Google Auth Library for PHP
google/recaptcha                    1.2.1              Client library for reCAPTCHA, a free service that protects...
grasmash/expander                   1.0.0              Expands internal property references in PHP arrays file.
grasmash/yaml-expander              1.4.0              Expands internal property references in a yaml file.
guzzlehttp/guzzle                   6.3.3              Guzzle is a PHP HTTP client library
guzzlehttp/promises                 v1.3.1             Guzzle promises library
guzzlehttp/psr7                     1.5.2              PSR-7 message implementation that also provides common uti...
guzzlehttp/ringphp                  1.1.1              Provides a simple API and specification that abstracts awa...
guzzlehttp/streams                  3.0.0              Provides a simple abstraction over streams of data
hamcrest/hamcrest-php               v2.0.0             This is the PHP port of Hamcrest Matchers
hoa/consistency                     1.17.05.02         The Hoa\Consistency library.
hoa/console                         3.17.05.02         The Hoa\Console library.
hoa/event                           1.17.01.13         The Hoa\Event library.
hoa/exception                       1.17.01.16         The Hoa\Exception library.
hoa/file                            1.17.07.11         The Hoa\File library.
hoa/iterator                        2.17.01.10         The Hoa\Iterator library.
hoa/protocol                        1.17.01.14         The Hoa\Protocol library.
hoa/stream                          1.17.02.21         The Hoa\Stream library.
hoa/ustring                         4.17.01.16         The Hoa\Ustring library.
jeremykendall/php-domain-parser     4.0.3-alpha        Public Suffix List based URL parsing implemented in PHP.
jeroendesloovere/vcard              1.5.0              This VCard PHP class can generate a vCard with some data. ...
justinrainbow/json-schema           5.2.8              A library to validate a json schema.
lcobucci/jwt                        3.2.5              A simple library to work with JSON Web Token and JSON Web ...
leafo/scssphp                       v0.7.7             scssphp is a compiler for SCSS written in PHP.
league/container                    2.4.1              A fast and intuitive dependency injection container.
league/event                        2.2.0              Event package
league/oauth2-server                5.1.6              A lightweight and powerful OAuth 2.0 authorization and res...
league/uri                          4.2.3              URI manipulation library
mikey179/vfsStream                  v1.6.6             Virtual file system to mock the real file system in unit t...
mockery/mockery                     1.2.2              Mockery is a simple yet flexible PHP mock object framework
monolog/monolog                     1.24.0             Sends your logs to files, sockets, inboxes, databases and ...
myclabs/deep-copy                   1.7.0              Create deep copies (clones) of your objects
nesbot/carbon                       1.37.1             A simple API extension for DateTime.
nikic/fast-route                    v1.3.0             Fast request router for PHP
onelogin/php-saml                   3.1.1              OneLogin PHP SAML Toolkit
paragonie/random_compat             v2.0.18            PHP 5.x polyfill for random_bytes() and random_int() from ...
php-cs-fixer/diff                   v1.3.0             sebastian/diff v2 backport support for PHP5.6
phpdocumentor/reflection-common     1.0.1              Common reflection classes used by phpdocumentor to reflect...
phpdocumentor/reflection-docblock   3.3.2              With this component, a library can provide support for ann...
phpdocumentor/type-resolver         0.4.0             
phpmailer/phpmailer                 v6.0.7             PHPMailer is a full-featured email creation and transfer c...
phpseclib/phpseclib                 2.0.15             PHP Secure Communications Library - Pure-PHP implementatio...
phpspec/prophecy                    1.8.0              Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage           4.0.8              Library that provides collection, processing, and renderin...
phpunit/php-file-iterator           1.4.5              FilterIterator implementation that filters files based on ...
phpunit/php-text-template           1.2.1              Simple template engine.
phpunit/php-timer                   1.0.9              Utility class for timing
phpunit/php-token-stream            1.4.12             Wrapper around PHP's tokenizer extension.
phpunit/phpunit                     5.7.27             The PHP Unit Testing framework.
phpunit/phpunit-mock-objects        3.4.4              Mock Object library for PHPUnit
pimple/pimple                       v3.2.3             Pimple, a simple Dependency Injection Container
psr/cache                           1.0.1              Common interface for caching libraries
psr/container                       1.0.0              Common Container Interface (PHP FIG PSR-11)
psr/http-message                    1.0.1              Common interface for HTTP messages
psr/log                             1.1.0              Common interface for logging libraries
ralouphie/getallheaders             2.0.5              A polyfill for getallheaders.
react/promise                       v2.7.1             A lightweight implementation of CommonJS Promises/A for PHP
roave/security-advisories           dev-master baeb6f5 Prevents installation of composer packages with known secu...
robrichards/xmlseclibs              3.0.3              A PHP library for XML Security
sebastian/code-unit-reverse-lookup  1.0.1              Looks up which function or method a line of code belongs to
sebastian/comparator                1.2.4              Provides the functionality to compare PHP values for equality
sebastian/diff                      1.4.3              Diff implementation
sebastian/environment               2.0.0              Provides functionality to handle HHVM/PHP environments
sebastian/exporter                  2.0.0              Provides the functionality to export PHP variables for vis...
sebastian/global-state              1.1.1              Snapshotting of global state
sebastian/object-enumerator         2.0.1              Traverses array structures and object graphs to enumerate ...
sebastian/recursion-context         2.0.0              Provides functionality to recursively process PHP variables
sebastian/resource-operations       1.0.0              Provides a list of PHP built-in functions that operate on ...
sebastian/version                   2.0.1              Library that helps with managing the version number of Git...
slim/slim                           3.12.1             Slim is a PHP micro framework that helps you quickly write...
soundasleep/html2text               0.5.0              A PHP script to convert HTML into a plain text format
symfony/browser-kit                 v3.4.27            Symfony BrowserKit Component
symfony/console                     v3.4.27            Symfony Console Component
symfony/css-selector                v3.4.27            Symfony CssSelector Component
symfony/debug                       v3.4.27            Symfony Debug Component
symfony/dom-crawler                 v3.4.27            Symfony DomCrawler Component
symfony/event-dispatcher            v3.4.27            Symfony EventDispatcher Component
symfony/filesystem                  v3.4.27            Symfony Filesystem Component
symfony/finder                      v3.4.27            Symfony Finder Component
symfony/options-resolver            v3.4.27            Symfony OptionsResolver Component
symfony/polyfill-ctype              v1.11.0            Symfony polyfill for ctype functions
symfony/polyfill-mbstring           v1.11.0            Symfony polyfill for the Mbstring extension
symfony/polyfill-php70              v1.11.0            Symfony polyfill backporting some PHP 7.0+ features to low...
symfony/polyfill-php72              v1.11.0            Symfony polyfill backporting some PHP 7.2+ features to low...
symfony/process                     v3.4.27            Symfony Process Component
symfony/stopwatch                   v3.4.28            Symfony Stopwatch Component
symfony/translation                 v3.4.27            Symfony Translation Component
symfony/validator                   v3.4.27            Symfony Validator Component
symfony/yaml                        v3.4.27            Symfony Yaml Component
tuupola/slim-jwt-auth               2.4.0              PSR-7 JWT Authentication Middleware
webmozart/assert                    1.4.0              Assertions to validate method input/output with nice error...
wikimedia/composer-merge-plugin     v1.4.1             Composer plugin to merge multiple composer.json files

modules:
  enabled:
    - \SuiteCRM\Test\Driver\WebDriver
  config:
    \SuiteCRM\Test\Driver\WebDriver:
      url: "http://localhost/"
      wait: 0
      port: 9515 # ChromeDriver port
      browser: chrome
      window_size: false
      clear_cookies: true
      capabilities:
        "goog:chromeOptions":
            args: ["--headless", "--disable-gpu", "--no-sandbox", "window-size=1920x1080"]
            binary: "/usr/bin/google-chrome-stable"
DavertMik commented 5 years ago

I think you can achieve this effect with retry functionality, which was introduced in 3.0 Just retry seeInPopup for a number of times.