Behat is based on the principles of BDD (Behavior-Driven Development). Basically, it is used to test the behavior of the application from end user’s point of view. Behat use Gherkin-language that is similar to English language and extended by custom PHP functions. These functions are written in FeatureContext.php file which is created inside the bootstrap folder.
Create file composer.json and behat.yml
composer.json : It consists of various dependencies that Behat requirement.
Create file composer.json and behat.yml
composer.json : It consists of various dependencies that Behat requirement.
composer.json
{
"require": {
"behat/behat": "3.3.1",
"behat/mink-extension": "2.3.1",
"behat/mink": "1.7.1",
"behat/mink-goutte-driver": "~1.2.0",
"behat/mink-selenium2-driver": "1.3.1",
"behat/symfony2-extension": "2.1.2",
"integratedexperts/behat-phpserver": "^0.1",
"peridot-php/webdriver-manager": "dev-master",
"bossa/phpspec2-expect": "1.*",
"integratedexperts/behat-screenshot": "^0.7.2",
"dmore/behat-chrome-extension": "^1.1",
"dmore/chrome-mink-driver": "^2.6"
},
"autoload": {
"psr-0": {
"Integratedexperts\\BehatScreenshot": "src/"
}
},
"config": {
"bin-dir": "bin"
},
"require-dev": {
"sensiolabs/behat-page-object-extension": "^2.0"
}
}
behat.yml : All configuration happens inside a single configuration file in the YAML format. Behat tries to load behat.yml like we can use our DOMAIN_URL.default: suites: default: contexts: - IntegratedExperts\BehatScreenshotExtension\Context\ScreenshotContext - FeatureContext extensions: IntegratedExperts\BehatScreenshotExtension: dir: %paths.base%/screenshots fail: true purge: false Behat\MinkExtension: base_url: 'DOMAIN_URL' browser_name: chrome sessions: default: selenium2: wd_host: http://127.0.0.1:4444/wd/hub
Make sure Chrome Browser and Chrome Driver are installed in your machine. if it is not installed please follow the step in this page.
https://www.linuxbabe.com/ubuntu/install-google-chrome-ubuntu-16-04-lt
For Chrome Driver:
https://tecadmin.net/setup-selenium-chromedriver-on-ubuntu/
wget https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip unzip chromedriver_linux64.zipYou can find the latest ChromeDriver on its official download page. Now execute below commands to configure ChromeDriver on your system.
sudo mv chromedriver /usr/bin/chromedriver
sudo chown root:root /usr/bin/chromedriver
sudo chmod +x /usr/bin/chromedriver
Execute “composer install” from your terminal. This command will read the ‘composer.json’ file from the current directory and execute it. It will install/update all the dependencies and its versions specified in a composer.json file.Download Selenium latest version https://www.seleniumhq.org/download/ or download tested from here. And put it in any location where do you want.
Run This command on Terminal on Respective location Selenium.It will run selenium server.
java -Dwebdriver.chrome.driver="/usr/bin/chromedriver" -jar selenium3.jar
The command “bin/behat --init” initializes Behat. This is to be run only once.Basically, it creates the directory structure.
Create Files inside features => abc.feature and features => bootstrap => FeatureContext.php
At last run command in other terminal bin/behat.
Comments
Post a Comment