SlideShare a Scribd company logo
Autotests
introduction
By Artur Babyuk
Agenda
● What is good auto QA test
● Codeception
○ Settings - YAML
○ Test code
○ Test organisation
○ Good practices
● Selenium, BrowserStack, PhpBrowser
● Jenkins
● And fun
What is good auto QA test?
Autotest is
1. Necessary
2. Stable
3. Simple
4. ...
Codeception
http://codeception.com/
https://gitlab.dyninno.net/qa-automation/TravelFrontendSeleniumTestingSystem
How we can run needed tests?
1. By file name or folder -> ./codecept run tests/acceptance/asap
2. By groups -> ./codecept run -g request -g phones
P.S. in documentation we see -> php codecept run -> ./codecept run do the same
thing
How to run tests on iOS or other platforms?
Settings
tests/acceptance.suite.yml
In config section:
Default settings for all envs
So by default we are using:
WebDriver at BrowserStack
Windows 10 + Chrome
Custom env
Envs:
nojs: with PhpBrowser
Testing asap.com project
local_asap: WebDriver
Running at our Selenium
Selenium vs PhpBrowser
Env (environment)
Is used for:
1. Testing host - run tests for prod, stage, or dev
2. Testing platform - run tests for iOS, Windows, Linux; Chrome or Safari
3. Testing resolution - run tests for laptops, full hd or 4K monitors
4. Tests executor - local Selenium, Selenium Grid, BrowserStack or PhpBrowser
5. Tests misc - GIFs of errors, Allure reporting...
Running tests for needed env
./codecept run acceptance --env local_asap
Combining all
./codecept run acceptance --env local_asap -g request --debug
P.S. --debug option for seeing all steps and additional information, but this make
tests slower
Jenkins
Is tool that executes tests (do the job) for you and where you can find test outputs
http://192.168.3.85/view/ASAP
Login: manager
Pass: xxxxxxx701
Create Jenkins job
1. Создать Item
2. Copy from -> use most green job name
3. Configure job at “Настройки” -> “Сборка” -> Exec command
4. Edit command where line ./codecept run …
Job :(
cd /home/gitlab-runner/TravelFrontendSeleniumTestingSystem/
git pull
./codecept run acceptance --env local_asap -g disclaimers
Autotests introduction - Codeception + PHP Basics
So, we can execute tests, how to write them?
Methodology
● Get the data from test subject
● Compare actual data with expected
Test are written in PHP
So we will use some PHP
Organizing tests
How can we get the test subject, if it is not
on current page???
1. Navigate to the page -> $I->amOnPage('/about');
2. Click -> $I->click('#nav a');
3. Fill forms -> $I->fillField('.user[email]','artur@babyuk.com');
4. Ask developers for help
What the heck just happened with $I-click()?
It is CSS selector, but there is many options
More info: https://blog.mozilla.org/webqa/2013/09/26/writing-reliable-locators-
for-selenium-and-webdriver-tests/
Comparing actual with expected
1. $I->see('Thank you'); $I->dontSee('Please enter email');
2. $I->seeElement('.success'); $I->dontSeeElement('.error');
3. $I->seeInCurrentUrl('/result-page'); $I->dontSeeInCurrentUrl('/oops');
4. Many other helper methods
But this is not so simple
There is problems - animation, network, designers and developers…
Some elements can lagg time to time or be not visible, but we need to autotest it
1. $I->wait(10);
2. $I->waitForElementVisible('.success', 10);
3. $I->waitForText('Success, we will contact you shortly', 30);
4. $I->waitForAllScriptsLoaded($I);
5. $I->scrollTo('footer');
Sometimes we need only to get data
1. $aLinkText = $I->grabMultiple('a');
2. $aLinks = $I->grabMultiple('a', 'href');
3. $url = $I->grabFromCurrentUrl();
4. $heading = $I->grabTextFrom('h1')
There is a lot of needed methods
http://codeception.com/docs/modules/WebDriver#Actions
You can also develop your common methods and put them here:
https://gitlab.dyninno.net/qa-
automation/TravelFrontendSeleniumTestingSystem/blob/master/tests/_support/
WebHelper.php
But tests are not so simple, how about
conditions?
https://clevertechie.com/php/5/php-if-else-statement
How about loops?
https://clevertechie.com/php/6/php-for-loop
How we can store expected results?
https://clevertechie.com/php/3/php-array
How we can loop an array?
https://clevertechie.com/php/8/php-foreach-loop
How about other useful functions?
1. count($elements);
2. strpos($airlineLogoHref, 'airlineNotFound') !== FALSE;
3. str_replace('-', ' ', $url);
4. preg_match('/[^A-Za-z0-9]/i', $onlyText);
5. empty($textOrArray);
6. date('m/d/Y', strtotime('+7 day'));
Autotests introduction - Codeception + PHP Basics
Home work

More Related Content

PPTX
Automation testing with Drupal 8
PDF
Behave manners for ui testing pycon2019
PPTX
Browser Automated Testing Frameworks - Nightwatch.js
PDF
Night Watch with QA
PPT
JavaScript Unit Testing
PDF
Javascript testing should be awesome
PDF
Profiling PHP with Xdebug / Webgrind
PDF
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
Automation testing with Drupal 8
Behave manners for ui testing pycon2019
Browser Automated Testing Frameworks - Nightwatch.js
Night Watch with QA
JavaScript Unit Testing
Javascript testing should be awesome
Profiling PHP with Xdebug / Webgrind
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017

What's hot (20)

PDF
淺談 Geb 網站自動化測試(JCConf 2014)
ZIP
Automated Frontend Testing
PDF
Front-end Automated Testing
PPTX
Frontend testing with Codeception
PDF
High Performance JavaScript 2011
PPTX
Code ceptioninstallation
PDF
3 WAYS TO TEST YOUR COLDFUSION API
PDF
JavaScript + Jenkins = Winning!
PDF
Debugging PHP With Xdebug
PDF
PPTX
Automated Testing with Cucumber, PhantomJS and Selenium
PDF
Testing Web Applications
PDF
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
PDF
CommandBox & ForgeBox Package Management
PDF
Join the darkside: Selenium testing with Nightwatch.js
PPTX
Automate testing with behat, selenium, phantom js and nightwatch.js (5)
PDF
[CLIW] Web testing
PDF
Test your Javascript! v1.1
PDF
Getting By Without "QA"
PDF
Debugging and Profiling in WordPress: What is My Site Doing?
淺談 Geb 網站自動化測試(JCConf 2014)
Automated Frontend Testing
Front-end Automated Testing
Frontend testing with Codeception
High Performance JavaScript 2011
Code ceptioninstallation
3 WAYS TO TEST YOUR COLDFUSION API
JavaScript + Jenkins = Winning!
Debugging PHP With Xdebug
Automated Testing with Cucumber, PhantomJS and Selenium
Testing Web Applications
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
CommandBox & ForgeBox Package Management
Join the darkside: Selenium testing with Nightwatch.js
Automate testing with behat, selenium, phantom js and nightwatch.js (5)
[CLIW] Web testing
Test your Javascript! v1.1
Getting By Without "QA"
Debugging and Profiling in WordPress: What is My Site Doing?
Ad

Similar to Autotests introduction - Codeception + PHP Basics (20)

PDF
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
PDF
Codeception introduction and use in Yii
PDF
Testing mit Codeception: Full-stack testing PHP framework
ODP
Behat Workshop at WeLovePHP
PDF
Good practices for debugging Selenium and Appium tests
PDF
Test driven development_continuous_integration
PDF
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
PDF
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
PDF
Making the most of your Test Suite
PPTX
Continuous feature-development
PDF
3 WAYS TO TEST YOUR COLDFUSION API -
PPTX
OWASP ZAP Workshop for QA Testers
PDF
Acceptance testing in php with Codeception - Techmeetup Edinburgh
PPT
Selenium testing - Handle Elements in WebDriver
PPTX
Automation Zaman Now
PDF
From devOps to front end Ops, test first
PPTX
Grunt Continuous Development of the Front End Tier
PDF
Automatic testing and quality assurance for WordPress plugins and themes
PDF
Gatling Performance Workshop
PPTX
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Codeception introduction and use in Yii
Testing mit Codeception: Full-stack testing PHP framework
Behat Workshop at WeLovePHP
Good practices for debugging Selenium and Appium tests
Test driven development_continuous_integration
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Making the most of your Test Suite
Continuous feature-development
3 WAYS TO TEST YOUR COLDFUSION API -
OWASP ZAP Workshop for QA Testers
Acceptance testing in php with Codeception - Techmeetup Edinburgh
Selenium testing - Handle Elements in WebDriver
Automation Zaman Now
From devOps to front end Ops, test first
Grunt Continuous Development of the Front End Tier
Automatic testing and quality assurance for WordPress plugins and themes
Gatling Performance Workshop
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Ad

Recently uploaded (20)

PDF
Cost to Outsource Software Development in 2025
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
medical staffing services at VALiNTRY
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
history of c programming in notes for students .pptx
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
Digital Strategies for Manufacturing Companies
PDF
System and Network Administraation Chapter 3
PPTX
Computer Software and OS of computer science of grade 11.pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Cost to Outsource Software Development in 2025
PTS Company Brochure 2025 (1).pdf.......
Digital Systems & Binary Numbers (comprehensive )
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
medical staffing services at VALiNTRY
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Design an Analysis of Algorithms II-SECS-1021-03
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
history of c programming in notes for students .pptx
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Digital Strategies for Manufacturing Companies
System and Network Administraation Chapter 3
Computer Software and OS of computer science of grade 11.pptx
Operating system designcfffgfgggggggvggggggggg
Softaken Excel to vCard Converter Software.pdf
Why Generative AI is the Future of Content, Code & Creativity?
Which alternative to Crystal Reports is best for small or large businesses.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus

Autotests introduction - Codeception + PHP Basics

  • 2. Agenda ● What is good auto QA test ● Codeception ○ Settings - YAML ○ Test code ○ Test organisation ○ Good practices ● Selenium, BrowserStack, PhpBrowser ● Jenkins ● And fun
  • 3. What is good auto QA test?
  • 4. Autotest is 1. Necessary 2. Stable 3. Simple 4. ...
  • 6. How we can run needed tests? 1. By file name or folder -> ./codecept run tests/acceptance/asap 2. By groups -> ./codecept run -g request -g phones P.S. in documentation we see -> php codecept run -> ./codecept run do the same thing
  • 7. How to run tests on iOS or other platforms?
  • 8. Settings tests/acceptance.suite.yml In config section: Default settings for all envs So by default we are using: WebDriver at BrowserStack Windows 10 + Chrome
  • 9. Custom env Envs: nojs: with PhpBrowser Testing asap.com project local_asap: WebDriver Running at our Selenium
  • 11. Env (environment) Is used for: 1. Testing host - run tests for prod, stage, or dev 2. Testing platform - run tests for iOS, Windows, Linux; Chrome or Safari 3. Testing resolution - run tests for laptops, full hd or 4K monitors 4. Tests executor - local Selenium, Selenium Grid, BrowserStack or PhpBrowser 5. Tests misc - GIFs of errors, Allure reporting...
  • 12. Running tests for needed env ./codecept run acceptance --env local_asap
  • 13. Combining all ./codecept run acceptance --env local_asap -g request --debug P.S. --debug option for seeing all steps and additional information, but this make tests slower
  • 14. Jenkins Is tool that executes tests (do the job) for you and where you can find test outputs http://192.168.3.85/view/ASAP Login: manager Pass: xxxxxxx701
  • 15. Create Jenkins job 1. Создать Item 2. Copy from -> use most green job name 3. Configure job at “Настройки” -> “Сборка” -> Exec command 4. Edit command where line ./codecept run …
  • 16. Job :( cd /home/gitlab-runner/TravelFrontendSeleniumTestingSystem/ git pull ./codecept run acceptance --env local_asap -g disclaimers
  • 18. So, we can execute tests, how to write them?
  • 19. Methodology ● Get the data from test subject ● Compare actual data with expected
  • 20. Test are written in PHP So we will use some PHP
  • 22. How can we get the test subject, if it is not on current page??? 1. Navigate to the page -> $I->amOnPage('/about'); 2. Click -> $I->click('#nav a'); 3. Fill forms -> $I->fillField('.user[email]','[email protected]'); 4. Ask developers for help
  • 23. What the heck just happened with $I-click()? It is CSS selector, but there is many options More info: https://blog.mozilla.org/webqa/2013/09/26/writing-reliable-locators- for-selenium-and-webdriver-tests/
  • 24. Comparing actual with expected 1. $I->see('Thank you'); $I->dontSee('Please enter email'); 2. $I->seeElement('.success'); $I->dontSeeElement('.error'); 3. $I->seeInCurrentUrl('/result-page'); $I->dontSeeInCurrentUrl('/oops'); 4. Many other helper methods
  • 25. But this is not so simple There is problems - animation, network, designers and developers… Some elements can lagg time to time or be not visible, but we need to autotest it 1. $I->wait(10); 2. $I->waitForElementVisible('.success', 10); 3. $I->waitForText('Success, we will contact you shortly', 30); 4. $I->waitForAllScriptsLoaded($I); 5. $I->scrollTo('footer');
  • 26. Sometimes we need only to get data 1. $aLinkText = $I->grabMultiple('a'); 2. $aLinks = $I->grabMultiple('a', 'href'); 3. $url = $I->grabFromCurrentUrl(); 4. $heading = $I->grabTextFrom('h1')
  • 27. There is a lot of needed methods http://codeception.com/docs/modules/WebDriver#Actions You can also develop your common methods and put them here: https://gitlab.dyninno.net/qa- automation/TravelFrontendSeleniumTestingSystem/blob/master/tests/_support/ WebHelper.php
  • 28. But tests are not so simple, how about conditions? https://clevertechie.com/php/5/php-if-else-statement
  • 30. How we can store expected results? https://clevertechie.com/php/3/php-array
  • 31. How we can loop an array? https://clevertechie.com/php/8/php-foreach-loop
  • 32. How about other useful functions? 1. count($elements); 2. strpos($airlineLogoHref, 'airlineNotFound') !== FALSE; 3. str_replace('-', ' ', $url); 4. preg_match('/[^A-Za-z0-9]/i', $onlyText); 5. empty($textOrArray); 6. date('m/d/Y', strtotime('+7 day'));