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 Behat Selenium on LambdaTest.
By the end of this topic, you will be able to:
Before you begin automation testing with Selenium and Behat, be ready with the below essentials:
1 |
sudo apt-get install curl libcurl3 libcurl3-dev php |
For Windows, you can download PHP from here. Also, refer to this documentation for ensuring the accessibility of PHP through Command Prompt(cmd).
1 |
php composer.phar require behat/behat |
If you don’t have composer installed in your system then click here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
{ "require": { "behat/behat": "2.5.*@stable", "facebook/webdriver": "dev-master", "symfony/yaml": "*" }, "config": { "bin-dir": "bin/" }, "scripts": { "test": "composer single && composer parallel", "single": "./bin/behat --config=config/single.conf.yml", "parallel": "CONFIG_FILE=config/parallel.conf.yml /usr/bin/env php lib/parallel.php" }, "autoload": { "classmap": ["lib/"] } } |
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 Behat GitHub repository for you to clone and play around.
1 2 3 4 5 6 7 8 9 |
Feature: Google's Search Functionality Scenario: Can find search results Given I am on "https://www.google.com/ncr" When I search for "LambdaTest" Then I get title as "LambdaTest - Google Search" |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
default: paths: features: '../features/single' bootstrap: '../features/bootstrap' context: parameters: lambdatest: server: "hub.lambdatest.com" user: "YOUR LT_USERNAME" key: "YOUR LT_ACCESS_KEY" capabilities: build: "behat-selenium-sample" name: "single-behat-test" video: true visual: true network: true console: true environments: - browserName: chrome version: 71.0 platform: Win10 |
You would need to execute the below command in your terminal/cmd.
1 |
composer single |