CAPABILITY GENERATOR

LambdaTest DocumentationAutomation Testing ● Codeception Integration With LambdaTest

Codeception Integration With LambdaTest


Powered by PHPUnit testing framework, and being BDD compatible, Codeception is a widely preferred test automation framework for performing unit testing, functional testing, and acceptance testing of a web application. Codeception provides versatile commands for validating structure and data of JSON & XML, so you could easily perform API testing throughout your extensive REST & SOAP API calls. Using Codeception with LambdaTest, you can execute automated cross browser testing across 2000+ browsers through our on-cloud Selenium Grid.

Prerequisites For Running PHP and Selenium


Before you begin automation testing with Selenium and PHP, be ready with the below essentials:

  • Install the latest PHP build for your OS. Mac OS X 5.3 or higher version comes with PHP installed. However, for windows users and linux users, you can download PHP from here.
    • If you are using Windows, to get better performance LambdaTest recommends to enable the PHP curl library and OpenSSL support from PHP setup.
    • Next step is to install Composer. Open up terminal and navigate to the folder that have PHP installed. Run the following command.

    • If you are using Xampp or Mamp you may have to open up PHP shell by pressing the button shown in picture below

    Once you have composer installed, you can leverage Composer to download and install Selenium dependencies. For that first create a composer.json file in your directory and add the following code to the json.

    Installing Selenium Dependencies For PHP


    Now, all you would have to do is to run composer to install Selenium. You can do that by running following command in your terminal:

    If you are using Xampp or Mamp you may have to be a little more specific.

    • Follow this documentation about Installing Extensions for Windows on the php.net website.
    • You can even download PHP with this link for your respective Windows or Linux OS.

    LambdaTest Authentication Credentials

    Be aware of your LambdaTest authentication credentials i.e. your LambdaTest username, access key and HubURL. You need to set them up as your environment variables. You can retrieve them from your LambdaTest automation dashboard by clicking on the key icon near the help button.

    • For Windows user:
    set LT_USERNAME="YOUR_USERNAME"
    set LT_ACCESS_KEY="YOUR ACCESS KEY"
    • For macOS/Linux user:
    export LT_USERNAME="YOUR_USERNAME"
    export LT_ACCESS_KEY="YOUR ACCESS KEY"

    Integrating Codeception With LambdaTest


    Now, that we are done with basic set up. We go ahead to run our first automation script through Codeception + LambdaTest Integration. Check out our GitHub repository for finding all the code references that will be discussed in this topic.

    Below is a sample acceptance test through PHP.

    Notice the declaration of class name “AcceptanceTester”. We used this class to specify test configuration, port number, browser name, browser version and other desired capabilities.

    IMPORTANT
    In the above code, remember to replace the token and username with respect to your LambdaTest account. You can find these values from LambdaTest dashboard. Your token would be the Access key.

    Configure Lambda Tunnel For Executing Your Codeception Tests With LambdaTest


    To help you perform cross browser testing of your locally stored web pages, LambdaTest provides an SSH(Secure Shell) tunnel connection with the name Lambda Tunnel. With Lambda Tunnel, you can execute a test of your locally hosted Codeception instance on cloud to perform automated cross browser testing on 2000+ browsers offered by Selenium Grid on LambdaTest. So you make sure how well your changes look, even before your customers. Curious to know more about Lambda Tunnel?

    Download:

    Once, the tunnel is successfully set up. You can add the below code to your capabilities for testing internal servers on your network.

    Tunnel Capabilities

    Follow our documentation on Lambda Tunnel to know it all. OS specific instructions to download and setup tunnel binary can be found at the following links.

    Running Tests With Codeception + LambdaTest


    Execute the below command and you are all good to go!