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

What's hot (20)

PDF
淺談 Geb 網站自動化測試(JCConf 2014)
Kyle Lin
 
ZIP
Automated Frontend Testing
Neil Crosby
 
PDF
Front-end Automated Testing
Ruben Teijeiro
 
PPTX
Frontend testing with Codeception
Christian Keuerleber
 
PDF
High Performance JavaScript 2011
Nicholas Zakas
 
PPTX
Code ceptioninstallation
Andrii Lagovskiy
 
PDF
3 WAYS TO TEST YOUR COLDFUSION API
Gavin Pickin
 
PDF
JavaScript + Jenkins = Winning!
Eric Wendelin
 
PDF
Debugging PHP With Xdebug
Mark Niebergall
 
PDF
Testing in go
Eduardo Felipe Ewert Bonet
 
PPTX
Automated Testing with Cucumber, PhantomJS and Selenium
Dev9Com
 
PDF
Testing Web Applications
Seth McLaughlin
 
PDF
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
Gavin Pickin
 
PDF
CommandBox & ForgeBox Package Management
Ortus Solutions, Corp
 
PDF
Join the darkside: Selenium testing with Nightwatch.js
Seth McLaughlin
 
PPTX
Automate testing with behat, selenium, phantom js and nightwatch.js (5)
Faichi Solutions
 
PDF
[CLIW] Web testing
Bogdan Gaza
 
PDF
Test your Javascript! v1.1
Eric Wendelin
 
PDF
Getting By Without "QA"
Dave King
 
PDF
Debugging and Profiling in WordPress: What is My Site Doing?
Peter Baylies
 
淺談 Geb 網站自動化測試(JCConf 2014)
Kyle Lin
 
Automated Frontend Testing
Neil Crosby
 
Front-end Automated Testing
Ruben Teijeiro
 
Frontend testing with Codeception
Christian Keuerleber
 
High Performance JavaScript 2011
Nicholas Zakas
 
Code ceptioninstallation
Andrii Lagovskiy
 
3 WAYS TO TEST YOUR COLDFUSION API
Gavin Pickin
 
JavaScript + Jenkins = Winning!
Eric Wendelin
 
Debugging PHP With Xdebug
Mark Niebergall
 
Automated Testing with Cucumber, PhantomJS and Selenium
Dev9Com
 
Testing Web Applications
Seth McLaughlin
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
Gavin Pickin
 
CommandBox & ForgeBox Package Management
Ortus Solutions, Corp
 
Join the darkside: Selenium testing with Nightwatch.js
Seth McLaughlin
 
Automate testing with behat, selenium, phantom js and nightwatch.js (5)
Faichi Solutions
 
[CLIW] Web testing
Bogdan Gaza
 
Test your Javascript! v1.1
Eric Wendelin
 
Getting By Without "QA"
Dave King
 
Debugging and Profiling in WordPress: What is My Site Doing?
Peter Baylies
 

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

PDF
Testing mit Codeception: Full-stack testing PHP framework
SusannSgorzaly
 
PPTX
Codeception
少東 張
 
PDF
Codeception presentation
Andrei Burian
 
PPT
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Puneet Kala
 
PDF
Acceptance testing in php with Codeception - Techmeetup Edinburgh
Engineor
 
PDF
How To Use Selenium Successfully (Java Edition)
Sauce Labs
 
PDF
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Dave Haeffner
 
PPTX
Getting Started With Selenium
SmartBear
 
PDF
Awesome Test Automation Made Simple w/ Dave Haeffner
Sauce Labs
 
PDF
Testing with Codeception
Jeremy Coates
 
PDF
Codeception Testing Framework -- English #phpkansai
Florent Batard
 
PDF
How To Use Selenium Successfully
Dave Haeffner
 
PDF
Selenium 2 for PHP(Unit)
AOE
 
PDF
How To Use Selenium Successfully
Dave Haeffner
 
PDF
Pdx Se Intro To Se
An Doan
 
PPTX
Test automation with php codeception
buddhieash
 
PDF
Mastering Test Automation: How to Use Selenium Successfully
Applitools
 
PPTX
Codeception @ New Business Dept Adira Finance
Fachrul Choliluddin
 
PDF
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Ondřej Machulda
 
PDF
Selenium Ide Tutorial
metapix
 
Testing mit Codeception: Full-stack testing PHP framework
SusannSgorzaly
 
Codeception
少東 張
 
Codeception presentation
Andrei Burian
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Puneet Kala
 
Acceptance testing in php with Codeception - Techmeetup Edinburgh
Engineor
 
How To Use Selenium Successfully (Java Edition)
Sauce Labs
 
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Dave Haeffner
 
Getting Started With Selenium
SmartBear
 
Awesome Test Automation Made Simple w/ Dave Haeffner
Sauce Labs
 
Testing with Codeception
Jeremy Coates
 
Codeception Testing Framework -- English #phpkansai
Florent Batard
 
How To Use Selenium Successfully
Dave Haeffner
 
Selenium 2 for PHP(Unit)
AOE
 
How To Use Selenium Successfully
Dave Haeffner
 
Pdx Se Intro To Se
An Doan
 
Test automation with php codeception
buddhieash
 
Mastering Test Automation: How to Use Selenium Successfully
Applitools
 
Codeception @ New Business Dept Adira Finance
Fachrul Choliluddin
 
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Ondřej Machulda
 
Selenium Ide Tutorial
metapix
 
Ad

Recently uploaded (20)

PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Ad

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'));