LambdaTest DocumentationAutomation Testing ● PHPUnit with Selenium – Running PHPUnit Automation Scripts on LambdaTest Selenium Grid

PHPUnit with Selenium – Running PHPUnit Automation Scripts on LambdaTest Selenium Grid

Execute your automation test scripts with Selenium WebDriver instantly through LambdaTest which is a cloud-based, cross browser testing tool offering a Selenium grid consisting 2000+ browsers and browser versions running on real operating systems to pace up automation testing of your web-app or website. In this topic, you will learn how to automate your website testing using Selenium with PHPUnit on LambdaTest.

By the end of this topic, you will be able to:

  • Run a sample Selenium with PHPUnit on LambdaTest Automation.
  • Set up an environment for testing your locally hosted web pages.
  • Understand & configure PHPUnit desired capabilities for executing a Selenium test.
  • Explore advanced features of LambdaTest.

Prerequisites For Running PHPUnit and Selenium

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

  • Make sure that you have PHP installed on your system. If you are using a Mac then PHP would be installed by default. For Linux you would need to enter the below command in terminal:
  • For Windows, you can download PHP from here. Also, refer to this documentation for ensuring the accessibility of PHP through Command Prompt(cmd).

  • Install PHPUnit using the below command with composer:
  • If you don’t have composer installed in your system then click here.

  • 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.
  • Check out our GitHub repository for finding all the code references that will be discussed in this topic.

Getting Started With PHPUnit and LambdaTest

Let us have a look at an example which will validate your LambdaTest credentials for authentication purpose. Later, the code will select the basic capabilities such as OS, browser, browser version and so on. This code is also available on our PHPUnit GitHub repository for you to clone and play around.(smile)

Now, Create LambdaTestSetup.php.

Now, Create globals.php

Now, finally add single.conf.json.

Execute The Test

You would need to execute the below command in your terminal/cmd.