7

Codeception wait for Selenium and Webdriver to start

 2 years ago
source link: https://www.mailslurp.com/blog/codeception-wait-for-selenium/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to wait for Selenium to start during Codeception tests

If you test using PHP and Codeception you may have run into the issue of how to start Selenium before your tests. Some people use a wait or sleep command but here is a tip to automatically start Selenium during tests and wait for it to start:

Configure acceptance.suite.yml

With the RunProcess extension with can add a special timeout wait command to wait for Selenium to start before starting our tests:

actor: AcceptanceTester
extensions:
    enabled:
        - Codeception\Extension\RunFailed
        # the lines will run the selenium server before tests start and wait for the process to answer on port 4444
        - Codeception\Extension\RunProcess:
            - java -Dwebdriver.gecko.driver=./geckodriver -jar selenium-server.jar
            - "timeout 300 bash -c 'while [[ \"$(curl -s -o /dev/null -w ''%{http_code}'' localhost:4444)\" != '200' ]]; do sleep 5; done' || false"
modules:
    enabled:
        - WebDriver:
           url: "https://playground.mailslurp.com"
           browser: firefox
        - \Helper\Acceptance
step_decorators: ~        

That’s it!

More information

For more tips on testing with Codeception see the PHP guide.


Related


Email APIs for developer and QA teams

MailSlurp is the leading email-as-a-service API system. Create unlimited disposable email accounts then send and receive emails from code and tests.

Create free account
App screenshot

What is MailSlurp?

MailSlurp is a free email API service for developers, QA testers and marketing campaigns. You can create disposable test mail accounts using the random email address generator via HTTP, GraphQL, dashboard or official code clients in Javascript, Csharp, Golang, Python, Java, Ruby, PHP and more!

What can MailSlurp do?

MailSlurp offers permanent email addresses using custom domains or random fake emails ending in @mailslurp.com. You can generate as many inboxes as you need for end-to-end email testing, email marketing campaigns and application development.

Getting started

Create a free MailSlurp account to get started using alternatives to MailTrap, Mailinator, Mailosaur and more. MailSlurp is the most advanced email platform with many features including: HTTP webhook push, graphql email APIs, sdks with long-polling (wait for emails), inbox forwarding, complex routing rulesets, and spam filters. See the pricing page for a full overview.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK